Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HTML history + back button to entry flow #823

Closed
wants to merge 27 commits into from

Conversation

gfodor
Copy link
Contributor

@gfodor gfodor commented Jan 5, 2019

Adds a back button to the entry flow and migrates the room page to use the HTML history API for all the various UI states.

image

This PR adds react-router and wires up the main room page to use routes. In dev mode we use hash history in prod it uses the real HTML history API.

Some notes:

  • If you refresh the page during the entry flow, we don't want to start you off in the middle of it, so there's a special case that just resets the path to "/" in that situation

  • If you enter the room and hit the back button, we don't want the entry flow to re-appear, and we also don't want you to end up on irrelevant URLs (eg the audio setup URL.) To get around this, if you hit back and end up being inside of the entry flow URL stack, the client just blows past it all and goes to the last history entry that was there before you landed on the page.

  • All the modal dialogs are now entered and exited using HTML history, except for the sign in flow, since we don't want to have the back button re-enter the sign in flow.

  • For modals, there's now the concept of the modal being successful or not (ie, was it not cancelled/closed with the X).

  • When a modal is closed with the X, we navigate back in the browser history (so the modal is effectively not going to appear again if you hit back) but if the modal is successful, then we push / back onto the stack, so the back button will re-show it. (Note: you will currently always be brought to /, not what you were on before the modal appeared -- right now isn't relevant in the current flows since the only modal this happens for is the create dialog (and you are always at / before that) but we may need to revisit this.) I'm not convinced this is the ideal behavior, but the scenario I am thinking of is when we have a scene/avatar/object browser and you hit OK, the back button probably should bring you back into the browser.

One somewhat negative side effect of doing this using react-router idomatically results in us building virtual dom elements for all the non-visible dialogs. (Whereas before we would short circuit building these elements using our own internal state flags.) I'm not sure we care.

I also fixed up vr_entry_type to seemingly work better with _now again.

@gfodor gfodor requested a review from brianpeiris January 5, 2019 01:20
@gfodor gfodor added the whats new Include this PR on the "What's New" page label Jan 5, 2019
@Hubs-Foundation Hubs-Foundation deleted a comment from buildsize bot Jan 5, 2019
@Hubs-Foundation Hubs-Foundation deleted a comment from buildsize bot Jan 5, 2019
Copy link
Contributor

@netpro2k netpro2k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad we are getting a router setup, as we add more stuff it will probably save us some mess. I also really like being able to go back in the entry flow, as I have had to reload tat due to a miss-click many times.

I do think we should simplify the back button rules to just:

  • if you are at the start of the entry flow, back returns to wherever you came to hubs from
  • If you are in the entry flow, back returns to previous step of the entry flow
  • if you are in a modal, back closes the modal
  • if you are in the room, back returns to the entry flow

I don't much see the point of hitting back to re-enter a modal, and feel like it will only build up a confusing habit that sometimes ends up booting you from the room on accident.

Also, made some suggestions on cleaning up the two hacks you had in the entry flow.

//
// This makes it so if we are in the room and hit back in the browser, we go to the URL
// the browser was on before the entry flow, not back into the entry flow.
this.props.history.listen((newLocation, action) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm this seems super fishy. The entered state should just be a route, and that route should replace all the entry flow routes in the history stack.

//
// Note this isn't perfect, if we refresh the page mid-entry flow and then hit back, we end
// up in a bad state unless we were on the first step. But this seems reasonable enough for now.
if (ENTRY_FLOW_ROUTES.find(x => x === this.props.history.location.pathname)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not 100% sure but I think you can push states with the same path, so instead of making each entry flow step its own path we can just have a pushState that has the current flow step in it, that way back button still works, but the url doesn't change so refreshing still goes back to the beginning for the flow. This combined with a replace on the actual entry should fix these 2 hacks.

src/hub.js Outdated
const Router =
process.env.RETICULUM_SERVER && process.env.RETICULUM_SERVER !== document.location.host
? HashRouter
: BrowserRouter;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember some nightmares with Android webviews and the BrowserRouter. Probably fine now, but worth giving extra care to testing Oculus Go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note this is just for dev


// We may need to go to a new path after saving.
if (this.props.location.state.postPushPath) {
this.props.history.push(this.props.location.state.postPushPath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. This goBack + conditional push feels odd. Being able to hit back to close the modal is maybe nice but I am not sure I expect to be able to go back to re-open a modal.

finished: "finished"
};
// This needs to be updated as we add modal routes.
const MODAL_ROUTES = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could alternatively define this as a state on the route or for bonus points make a ModalRoute component that does so, so you define this property as part of defining the route.

@@ -228,17 +270,17 @@ class UIRoot extends Component {
onContinueAfterSignIn();
};

this.showDialog(SignInDialog, {
this.showNonHistoriedDialog(SignInDialog, {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like I said above I would vote all the modals are non historied except that hitting back can close them. Seems simpler than having 2 different types.

if (success) {
this.props.history.push("/");
} else {
this.props.history.goBack();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means I will be able to go "forward" into the dialog, not sure that is desirable.

// This makes it so if you create an object, back will re-show the create object dialog,
// but if you cancel, it will not.
if (success) {
this.props.history.push("/");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, not sure I really desire to hit back to re-open the dialog. I feel like if I am looking at a hubs room, hitting back should take me back to the lobby, if I am looking at a modal, it should close the modal.

@Hubs-Foundation Hubs-Foundation deleted a comment from buildsize bot Jan 10, 2019
@buildsize
Copy link

buildsize bot commented Jan 12, 2019

File name Previous Size New Size Change
avatar-selector.html 922 bytes 922 bytes 0 bytes (0%)
favicon.ico 33.69 KB 33.69 KB 0 bytes (0%)
hub-preview.png 16.5 KB 16.5 KB 0 bytes (0%)
hub.html 46.1 KB 46.1 KB 0 bytes (0%)
index.html 695 bytes 695 bytes 0 bytes (0%)
link.html 803 bytes 803 bytes 0 bytes (0%)
LoadingObject_Atom-[hash].glb 27.43 KB 27.43 KB 0 bytes (0%)
waternormals-[hash].jpg 242.98 KB 242.98 KB 0 bytes (0%)
bubble_off-[hash].png 4.22 KB 4.22 KB 0 bytes (0%)
bubble_off-hover-[hash].png 5.85 KB 5.85 KB 0 bytes (0%)
bubble_on-[hash].png 5.65 KB 5.65 KB 0 bytes (0%)
bubble_on-hover-[hash].png 5.46 KB 5.46 KB 0 bytes (0%)
create_object-[hash].png 8.38 KB 8.38 KB 0 bytes (0%)
create_object-hover-[hash].png 10.65 KB 10.65 KB 0 bytes (0%)
freeze_off-[hash].png 7.53 KB 7.53 KB 0 bytes (0%)
freeze_off-hover-[hash].png 9.96 KB 9.96 KB 0 bytes (0%)
freeze_on-[hash].png 7.36 KB 7.36 KB 0 bytes (0%)
freeze_on-hover-[hash].png 9.45 KB 9.45 KB 0 bytes (0%)
mute_off-[hash].png 2.76 KB 2.76 KB 0 bytes (0%)
mute_off-hover-[hash].png 3.65 KB 3.65 KB 0 bytes (0%)
mute_on-[hash].png 5.48 KB 5.48 KB 0 bytes (0%)
mute_on-hover-[hash].png 5.29 KB 5.29 KB 0 bytes (0%)
spawn_photo-[hash].png 3.14 KB 3.14 KB 0 bytes (0%)
tooltip.9-[hash].png 640 bytes 640 bytes 0 bytes (0%)
account-[hash].svg 826 bytes 826 bytes 0 bytes (0%)
daydream_entry-[hash].svg 6.47 KB 6.47 KB 0 bytes (0%)
default_thumbnail-[hash].png 3.02 KB 3.02 KB 0 bytes (0%)
desktop_screen_entry-[hash].svg 376 bytes 376 bytes 0 bytes (0%)
device_entry-[hash].svg 10.48 KB 10.48 KB 0 bytes (0%)
dropdown_arrow-[hash].png 172 bytes 172 bytes 0 bytes (0%)
dropdown_arrow@2x-[hash].png 233 bytes 233 bytes 0 bytes (0%)
gearvr_entry-[hash].svg 574 bytes 574 bytes 0 bytes (0%)
generic_vr_entry-[hash].svg 952 bytes 952 bytes 0 bytes (0%)
giphy_logo-[hash].png 1.02 KB 1.02 KB 0 bytes (0%)
level_background-[hash].png 4.03 KB 4.03 KB 0 bytes (0%)
level_background@2x-[hash].png 4.63 KB 4.63 KB 0 bytes (0%)
level_fill-[hash].png 1.03 KB 1.03 KB 0 bytes (0%)
level_fill@2x-[hash].png 2.02 KB 2.02 KB 0 bytes (0%)
logo-[hash].svg 14.21 KB 14.21 KB 0 bytes (0%)
mic_denied-[hash].png 2.02 KB 2.02 KB 0 bytes (0%)
mic_denied@2x-[hash].png 3.97 KB 3.97 KB 0 bytes (0%)
mic_granted-[hash].png 2.21 KB 2.21 KB 0 bytes (0%)
mic_granted@2x-[hash].png 4.26 KB 4.26 KB 0 bytes (0%)
mic_level-[hash].png 697 bytes 697 bytes 0 bytes (0%)
mic_level@2x-[hash].png 1.48 KB 1.48 KB 0 bytes (0%)
mic_small-[hash].png 234 bytes 234 bytes 0 bytes (0%)
mic_small@2x-[hash].png 370 bytes 370 bytes 0 bytes (0%)
mobile_screen_entry-[hash].svg 914 bytes 914 bytes 0 bytes (0%)
speaker_level-[hash].png 626 bytes 626 bytes 0 bytes (0%)
speaker_level@2x-[hash].png 1.29 KB 1.29 KB 0 bytes (0%)
warning_icon-[hash].png 442 bytes 442 bytes 0 bytes (0%)
warning_icon@2x-[hash].png 699 bytes 699 bytes 0 bytes (0%)
aframe-inspector.min-[hash].js 384.44 KB 384.44 KB 0 bytes (0%)
avatar-selector-[hash].js 54.97 KB 55 KB 23 bytes (0%)
avatar-selector-[hash].js.map 134.09 KB 134.08 KB -17 bytes (0%)
engine-[hash].js 1.41 MB 1.41 MB 25 bytes (0%)
engine-[hash].js.map 4.44 MB 4.45 MB 5.26 KB (0%)
gifparsing.worker-[hash].js 1.92 KB 1.92 KB 0 bytes (0%)
gifparsing.worker-[hash].js.map 8.33 KB 8.33 KB 0 bytes (0%)
hub-[hash].js 464.1 KB 470.96 KB 6.85 KB (1%)
hub-[hash].js.map 1.2 MB 1.22 MB 17.1 KB (1%)
index-[hash].js 43.86 KB 43.89 KB 30 bytes (0%)
index-[hash].js.map 89.64 KB 89.28 KB -372 bytes (0%)
link-[hash].js 34.4 KB 34.42 KB 20 bytes (0%)
link-[hash].js.map 80.31 KB 80.33 KB 21 bytes (0%)
sketchfab-zip.worker-[hash].js 155.05 KB 155.05 KB 0 bytes (0%)
sketchfab-zip.worker-[hash].js.map 774.31 KB 774.31 KB 0 bytes (0%)
vendor-[hash].js 1.44 MB 1.48 MB 41.7 KB (3%)
vendor-[hash].js.map 4.94 MB 5.09 MB 149.53 KB (3%)
quack-[hash].mp3 7.03 KB 7.03 KB 0 bytes (0%)
specialquack-[hash].mp3 11.57 KB 11.57 KB 0 bytes (0%)
tone-[hash].mp3 53.92 KB 53.92 KB 0 bytes (0%)
tone-[hash].wav 385.29 KB 385.29 KB 0 bytes (0%)
tone-[hash].webm 32.04 KB 32.04 KB 0 bytes (0%)
tone-[hash].ogg 32.55 KB 32.55 KB 0 bytes (0%)
avatar-selector-[hash].css 1.15 KB 1.15 KB 0 bytes (0%)
avatar-selector-[hash].css.map 136 bytes 136 bytes 0 bytes (0%)
hub-[hash].css 88.68 KB 89.39 KB 734 bytes (1%)
hub-[hash].css.map 124 bytes 124 bytes 0 bytes (0%)
index-[hash].css 38.74 KB 38.74 KB 0 bytes (0%)
index-[hash].css.map 126 bytes 126 bytes 0 bytes (0%)
link-[hash].css 6.1 KB 6.1 KB 0 bytes (0%)
link-[hash].css.map 125 bytes 125 bytes 0 bytes (0%)
home-[hash].mp4 2 MB 2 MB 0 bytes (0%)
home-[hash].webm 1.81 MB 1.81 MB 0 bytes (0%)
negx-[hash].jpg 54.45 KB 54.45 KB 0 bytes (0%)
negy-[hash].jpg 50.97 KB 50.97 KB 0 bytes (0%)
negz-[hash].jpg 53.29 KB 53.29 KB 0 bytes (0%)
posx-[hash].jpg 58.64 KB 58.64 KB 0 bytes (0%)
posy-[hash].jpg 19.17 KB 19.17 KB 0 bytes (0%)
posz-[hash].jpg 57.49 KB 57.49 KB 0 bytes (0%)
spawn_pen-[hash].png 2.39 KB 2.39 KB 0 bytes (0%)
spawn_pen-hover-[hash].png 3.07 KB 3.07 KB 0 bytes (0%)
spawn_camera-[hash].png 4.92 KB 4.92 KB 0 bytes (0%)
spawn_camera-hover-[hash].png 5.83 KB 5.83 KB 0 bytes (0%)
scene.html 1.92 KB 1.92 KB 0 bytes (0%)
scene-[hash].js 118.23 KB 118.27 KB 36 bytes (0%)
scene-[hash].js.map 291.2 KB 291.43 KB 236 bytes (0%)
scene-[hash].css 10.91 KB 10.91 KB 0 bytes (0%)
scene-[hash].css.map 126 bytes 126 bytes 0 bytes (0%)
camera_tool-[hash].glb 757.23 KB 757.23 KB 0 bytes (0%)
hub-preview-white-[hash].png 62.76 KB 62.76 KB 0 bytes (0%)
link_dialog_header-[hash].svg 950 bytes 950 bytes 0 bytes (0%)
moz-logo-black-[hash].png 1.71 KB 1.71 KB 0 bytes (0%)
hub-preview-light-no-shadow-[hash].png 9.35 KB 9.35 KB 0 bytes (0%)
spoke.html 1.42 KB 1.42 KB 0 bytes (0%)
spoke-[hash].js 16.71 KB 16.73 KB 22 bytes (0%)
spoke-[hash].js.map 27.9 KB 27.89 KB -12 bytes (0%)
spoke-[hash].css 6.32 KB 6.32 KB 0 bytes (0%)
spoke-[hash].css.map 126 bytes 126 bytes 0 bytes (0%)
spoke_logo-[hash].png 148.82 KB 148.82 KB 0 bytes (0%)
spoke_logo_black-[hash].png 45.87 KB 45.87 KB 0 bytes (0%)
twitter-[hash].svg 869 bytes 869 bytes 0 bytes (0%)
tap_mellow-[hash].wav 624 bytes 624 bytes 0 bytes (0%)
presence_desktop-[hash].png 252 bytes 252 bytes 0 bytes (0%)
presence_phone-[hash].png 237 bytes 237 bytes 0 bytes (0%)
presence_vr-[hash].png 558 bytes 558 bytes 0 bytes (0%)
hub.service.js 1.34 KB 1.34 KB 0 bytes (0%)
spoke-[hash].webm 5.52 MB 5.52 MB 0 bytes (0%)
spoke-[hash].mp4 6.27 MB 6.27 MB 0 bytes (0%)
action_button.9-[hash].png 2.08 KB 2.08 KB 0 bytes (0%)
spawn_message-[hash].png 625 bytes 625 bytes 0 bytes (0%)
share_camera_off-[hash].png 4.08 KB 4.08 KB 0 bytes (0%)
share_camera_on-[hash].png 6.58 KB 6.58 KB 0 bytes (0%)
share_camera_on-hover-[hash].png 4.44 KB 4.44 KB 0 bytes (0%)
share_screen_off-[hash].png 4.22 KB 4.22 KB 0 bytes (0%)
share_screen_on-[hash].png 6.66 KB 6.66 KB 0 bytes (0%)
share_screen_on-hover-[hash].png 6.8 KB 6.8 KB 0 bytes (0%)
share_window_off-[hash].png 4.13 KB 4.13 KB 0 bytes (0%)
share_window_on-[hash].png 6.62 KB 6.62 KB 0 bytes (0%)
share_window_on-hover-[hash].png 6.7 KB 6.7 KB 0 bytes (0%)
A_bendUp-[hash].wav 60.04 KB 60.04 KB 0 bytes (0%)
Eb_blip-[hash].wav 5.88 KB 5.88 KB 0 bytes (0%)
PenDraw1-[hash].wav 16.04 KB 16.04 KB 0 bytes (0%)
PenSpawn-[hash].wav 12.04 KB 12.04 KB 0 bytes (0%)
PicSnapHey-[hash].wav 120.04 KB 120.04 KB 0 bytes (0%)
quickTurn-[hash].wav 16.04 KB 16.04 KB 0 bytes (0%)
share_message-[hash].png 18.9 KB 18.9 KB 0 bytes (0%)
presence-count-[hash].png 1.78 KB 1.78 KB 0 bytes (0%)
pop-[hash].wav 192.54 KB 192.54 KB 0 bytes (0%)
tack-[hash].wav 40.84 KB 40.84 KB 0 bytes (0%)
suspense-[hash].wav 508.04 KB 508.04 KB 0 bytes (0%)
teleportArc-[hash].wav 184.04 KB 184.04 KB 0 bytes (0%)
welcome-[hash].wav 830.82 KB 830.82 KB 0 bytes (0%)
tick-[hash].wav 8.04 KB 8.04 KB 0 bytes (0%)
whats-new.html 721 bytes 721 bytes 0 bytes (0%)
whats-new-[hash].js 49.75 KB 49.75 KB 0 bytes (0%)
whats-new-[hash].js.map 240.13 KB 240.13 KB 1 bytes (0%)
whats-new-[hash].css 2.68 KB 2.68 KB 0 bytes (0%)
whats-new-[hash].css.map 130 bytes 130 bytes 0 bytes (0%)
generic_vr_headset-[hash].svg 950 bytes 950 bytes 0 bytes (0%)

@brianpeiris
Copy link
Contributor

Merging in #843

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
whats new Include this PR on the "What's New" page
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants