leaguevine / leaguevine-ultistats

MIT License
18 stars 4 forks source link

Better method for navigating away from the game tracking page #33

Open mliu7 opened 12 years ago

mliu7 commented 12 years ago

At the moment the only way to navigate away from the game tracking page is to click the browser "back" button. However, there is an issue with this because of authentication. If an unauthenticated user navigates to the game tracking page, we redirect them to the oauth page and ask them to authenticate. After they log in successfully, they are redirected to the game tracking page. Now, navigating away from the game tracking page will take them back to the oauth page, which is not the behavior we want.

If we kept our navigation bar at the top of the game tracking page like all the other pages, would that hurt performance much?

If the performance is ok, I'm thinking we keep the regular black navigation bar there, and none of the 4 options (team, tournament, game, settings) would be highlighted. Thus, clicking on game would take the user back to the game detail page where they could view the stats.

I'm not worried about screen real estate since the game tracking page actually takes up very little space. Also, I don't think we would need a title bar on that page.

cboulay commented 12 years ago

I think the easier solution to the problem is to have authentication return the user to the game detail screen, where they must click on "take stats" once more.

I haven't looked at the CSS so I don't know if you're using relative sizes or not. In any case, we absolutely cannot allow the game tracking page to scroll and we should use 100% of the available space for buttons or information. Bigger buttons means more data (less effort -> more users) and more accurate data.

cboulay commented 12 years ago

I forgot to add: I think the buttons are a little too small right now, and I'm on a 4.3" screen.

mliu7 commented 12 years ago

I think your solution for navigating back to the game page works fine for this case.

I agree that this page shouldn't scroll and that everything needs to be visible at all times, maximizing the height and width of the screen. I just opened a new issue to address the vertical alignment that you brought up. On my iPhone, the buttons take up the full height of the screen, but on the Android that I'm testing on it takes up only 2/3 of the screen.

cboulay commented 12 years ago

While unlikely, users can get to the trackedgame page through a URL. The back button behavior would then be broken. I'm a bit tired so I can't think of a good solution to this right now... but if we have the trackedgame page check for authentication (but not navigate to oauth page) and then if not authenticated we navigate to the game detail page. The game detail page could then check authentication and navigate to the oauth page if not authenticated. This would leave users that are already logged in AND navigate directly to the trackedgame page. How can we handle them?

Would a better solution be to simply check if someone came to the URL directly (i.e., not through the Backbone.navigate) and then kick those people back to the gamedetail page?

What do you think?

mliu7 commented 12 years ago

I think your second solution (checking if they navigated directly and then kicking them back to the game detail page) is a much better option. I can't think of a better solution, and am down for solving it this way.

cboulay commented 12 years ago

Great, but I don't know how to do that.

The solution might be even simpler. If we don't want them to navigate to this page directly then this page shouldn't be accessible via the router. Clicking on "Take Stats" shouldn't be an href but instead should fire an event that loads the trackedgame page. BUT then we need to create a duplicate entry in the Browser's history so that back will take them back to the same page. I think we can do that with Backbone's app.navigate, but I'm not sure if the browser will respect the duplicate entry. I'll have to test that.

I think the back button functionality is important so if I can't get it to work using the above method I'll keep the page URL accessible but detect where the user came from. Do you have any hints on how to do that?

mliu7 commented 12 years ago

I think messing with the Backbone navigation sounds dangerous and is opening up a whole new can of worms. I'd rather just detect where the user came from. How about just looking at the document.referrer variable and seeing if it ends with #games/12345 or whatever the ID is for the game?

http://stackoverflow.com/questions/3528324/how-do-you-get-the-previous-url-in-javascript