Posts from 28 January 2015
Now that we don't have to blog, I can blog whenever I want—which also means blogging in the middle of the day when I've found some solution to a particularly knotty annoyance and am taking a break from whatever.
I'll try to keep this quick, and I still don't have it how I want it.
Sign-in is handled through a modal (using a library that is just okay…). When the app first starts, it tries fetching the
currentUsermodel (asynchronously, of course). Meanwhile, it tries to route to whichever route was input, and if the user isn't signed in (which he won't be, because we're still waiting on a server response), it redirects to the sign-in window, which has an initializer that tells it to destroy itself when it receives a
'signIn'event over the Backbone.Radio
Meanwhile, the modal animates, and only adds its keybindings once the animation is finished. But the
'signIn'event is received in the middle of the animation, which means that the view is
destroy()ed before it has attached its keybindings… which it does after the fact.
Long story short, when a signed-in user refreshes the page, the sign-in modal installs listeners that get uninstalled before they're installed, and the next time the user hits "enter" the modal executes a "submit" event on empty text fields.
I got around it by having an
onShowcallback that checks to see if we're signed in, and ONCE THAT CHECK HAPPENS, install the
'signIn'event listener. If that check fails (we've signed in during the 100ms that the animation has as default) then we uninstall ourselves.