codeforamerica / fast_pass

Las Vegas Development Opportunity Finder
BSD 3-Clause "New" or "Revised" License
7 stars 4 forks source link

Load session from server before pages are displayed #89

Closed lovehandle closed 10 years ago

lovehandle commented 10 years ago

At the moment, session information is loaded asynchronously from the server, but various components on the website (e.g. naics search input) are populated with values from the session.

Page components that rely on session data are looking for values that haven't been loaded yet from the server, and consequently they appear to be blank (even though their values exist within the soon to be loaded session).

Repeatable by loading a specific step that has session data (i.e. go to step 15, hard refresh the page, no text will be present in textarea, go to the next step, go back to step 15, session data should be loaded now and will appear within the textarea).

@louh I want to postpone loading the entire application until the session data has been loaded from the server. If the connection is slow it may take a few seconds. Do you have any thoughts? Maybe load the first page, and display a loading overlay?

louh commented 10 years ago

@rclosner I think your proposal works. If a visitor shows up on the application at an arbitrary entry point, how would it even know what the user's current page is until the session data is loaded? So I think directing to a loading screen first, then redirecting after session data is loaded makes sense. (Streetmix works a similar way).

lovehandle commented 10 years ago

So, I've currently added a hook that loads the session before each page is displayed, but I'm not sure how elegant it is.

You can see the implementation of the wrapper function here: https://github.com/codeforamerica/fast_pass/blob/master/public/js/controllers.js#L17

You can see how it is used here: https://github.com/codeforamerica/fast_pass/blob/master/public/js/controllers.js#L61

Also, that's a really fantastic point. At the moment I'm not redirecting to the last used page, but we really should be doing that.

Regardless, I'm going to close seeing as the session data is now being loaded.