Skip to content

Commit

Permalink
Go back to using query params since GitHub pages doesn't allow path p…
Browse files Browse the repository at this point in the history
…arams
  • Loading branch information
mrnyby committed Feb 5, 2024
1 parent 93a0ac6 commit f734414
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions docs/assets/index-n6gDUmmp.js → docs/assets/index-uT-_ECYj.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<link rel="icon" type="image/svg+xml" href="/fivel/favicon.svg" />
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<script type="module" crossorigin src="/fivel/assets/index-n6gDUmmp.js"></script>
<script type="module" crossorigin src="/fivel/assets/index-uT-_ECYj.js"></script>
<link rel="stylesheet" crossorigin href="/fivel/assets/index-hXRC8c0Z.css">
</head>

Expand Down
3 changes: 1 addition & 2 deletions src/components/dialog/CreateGameDialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@
return;
}
const baseUrl = window.location.href.split("/").slice(0, 4).join("/");
const gameConfig = new GameConfig(
lowerCaseWord,
// If gameId/hint aren't set, pass them in as undefined to save URL space when encoding this GameConfig
gameId === "" ? undefined : gameId,
hint === "" ? undefined : hint
);
link = `${baseUrl}/${gameConfig.serialize()}`;
link = `${window.location.href.split("?")[0]}?f=${gameConfig.serialize()}`;
navigator.clipboard.writeText(link).then(() => {
isPopoverOpen = true;
Expand Down
7 changes: 4 additions & 3 deletions src/stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ const _createKeyColors = () => {
};
};

const serializedGameConfig = window.location.pathname.split("/")[2];
const _urlParams = new URLSearchParams(window.location.search);
const _serializedGameConfig = _urlParams.get("f");

export const guesses = _createGuesses();
export const guessesAreExhausted = derived(guesses, $guesses => $guesses.every(guess => guess.isSubmitted));
Expand All @@ -100,7 +101,7 @@ export const nextCharacterIndices = derived(guesses, $guesses => {
const nextCharacterIndex = $guesses[nextGuessIndex].characters.findIndex(character => character.value === "");
return [nextGuessIndex, nextCharacterIndex] as [number, number];
});
export const gameConfig = readable(serializedGameConfig === "" ? null : GameConfig.deserialize(serializedGameConfig));
export const gameConfig = readable(_serializedGameConfig === null ? null : GameConfig.deserialize(_serializedGameConfig));

export const createGameDialogIsVisible = writable(serializedGameConfig === "");
export const createGameDialogIsVisible = writable(_serializedGameConfig === null);
export const postGameDialogIsVisible = writable(false);

0 comments on commit f734414

Please sign in to comment.