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

Adding back button & reload support #495

Open
wants to merge 9 commits into
base: localisation
Choose a base branch
from

Conversation

jakearchibald
Copy link
Contributor

@jakearchibald jakearchibald commented Aug 6, 2019

DON'T MERGE. This is based on the localisation work, so they'll need to land in that order (unless I untangle it, which isn't too hard).

Fixes #412.

@jakearchibald jakearchibald requested review from surma and kosamari August 6, 2019 15:24
@@ -24,17 +24,20 @@ if (!self.define) {
if (registry[name]) {
return;
}

const url = '/' + name;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to do this to prevent 404s, when it tried to request stuff like /game/index-abcdef.js

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean 'game/index-abcdef.js'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes

gameTypeToURL(width, height, mines, usedKeyboard)
);
}
// /TODO
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can remove this once we're confident few people are upgrading from versions that used immedateGameSessionKey.

I'll create an issue for that.

@jakearchibald
Copy link
Contributor Author

Hmm, the rewrite rule is not working

@jakearchibald
Copy link
Contributor Author

Hold off reviewing while I fix shit

@jakearchibald jakearchibald changed the base branch from localisation to master August 6, 2019 16:22
@jakearchibald jakearchibald changed the base branch from master to localisation August 6, 2019 16:22
@jakearchibald
Copy link
Contributor Author

@surma @kosamari right, I'm happy with this now

Copy link
Contributor

@surma surma left a comment

Choose a reason for hiding this comment

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

Yeah this looks good to me!

@PaulKinlan is gonna be so happy.

@@ -24,17 +24,20 @@ if (!self.define) {
if (registry[name]) {
return;
}

const url = '/' + name;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean 'game/index-abcdef.js'?

return;
}

if (!location.pathname.startsWith("/game/")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like the 2 if and the one inverted if are easy to trip over. Would a classic switch be more readable here?

const [,component] = location.pathname.split("/");
switch(component) {
  case "": // start screen
	// ...
    break;
  case "about":
    // ...
    break;
  case "game":
    // ...
    break;
  default:
    this._resetToStartScreen()
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I'll find a better pattern here

if (!usedKeyboard) {
// This is a horrible hack to tell focus-visible.js not to initially show focus styles.
document.body.dispatchEvent(
new MouseEvent("mousemove", { bubbles: true })
Copy link
Contributor

Choose a reason for hiding this comment

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

lol works for me :D (But also cc @robdodson)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This code exists already, I've just moved it. WICG/focus-visible#198

Choose a reason for hiding this comment

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

just checking, is there anything I need to do on my end?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh no, sorry. I just wanted to make sure you are aware of this hack in case we were missing something. I didn’t know that Jake already filed an issue ages ago.

if (
url.pathname === "/" ||
url.pathname === "/about/" ||
url.pathname.startsWith("/game/")
Copy link
Contributor

Choose a reason for hiding this comment

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

I worry about having to keeping the pages the router knows about in sync with the pages the service worker knows about. We don't need to solve it in this PR, but maybe we should just switch to always delivering index.html on 404 for requests then end in /, .html or have no file extension?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That won't work offline though (and has the lifi problem). I agree it's a problem though. I guess we should create a seperate file of rewrites that feeds into this and _redirects.

@Ishaan28malik
Copy link

@jakearchibald is anything still left in this issue , which is not yet resolved ?

@surma
Copy link
Contributor

surma commented Aug 7, 2019

is anything still left in this issue

I mean, I did leave comments that Jake wanted to address.

@jakearchibald
Copy link
Contributor Author

The big "DON'T MERGE" thing is a clue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants