-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: store ws client's current url (#123)
- Loading branch information
1 parent
6c77c0e
commit 363b1ae
Showing
10 changed files
with
259 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import htmx from './htmx.js' | ||
|
||
/** | ||
* @typedef WsSend | ||
* @type {function} | ||
* @param {string} message | ||
*/ | ||
|
||
/** | ||
* @typedef SocketWrapper | ||
* @type {object} | ||
* @property {WsSend} send | ||
*/ | ||
|
||
/** @type {SocketWrapper} */ | ||
let socket | ||
|
||
export function reportNavigation(/** @type {string} */ path) { | ||
const msg = JSON.stringify({ navigated: path }) | ||
socket?.send(msg) | ||
} | ||
|
||
/** | ||
* @param {{detail: {socketWrapper: SocketWrapper}}} event | ||
*/ | ||
htmx.on('htmx:wsOpen', event => { | ||
socket = event.detail.socketWrapper | ||
reportNavigation(window.location.pathname) | ||
}) | ||
|
||
htmx.on('htmx:pushedIntoHistory', ({ detail }) => { | ||
reportNavigation(detail.path) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
src/players/views/html/go-to-game.tsx → src/games/views/html/go-to-game.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.