diff --git a/src/client/account.ts b/src/client/account.ts index a3fe082a22bce52f7594af613da5025027c55b7b..a2165ebed11b4e4fcb93f269b3dc551d92e91d2f 100644 --- a/src/client/account.ts +++ b/src/client/account.ts @@ -61,7 +61,7 @@ export async function signout() { document.cookie = `igi=; path=/`; if (accounts.length > 0) login(accounts[0].token); - else unisonReload(); + else unisonReload('/'); } export async function getAccounts(): Promise<{ id: Account['id'], token: Account['token'] }[]> { @@ -122,7 +122,9 @@ export async function login(token: Account['token'], redirect?: string) { await addAccount(me.id, token); if (redirect) { - reloadChannel.postMessage('reload'); + // ä»–ã®ã‚¿ãƒ–ã¯å†èªã¿è¾¼ã¿ã™ã‚‹ã ã‘ + reloadChannel.postMessage(null); + // ã“ã®ãƒšãƒ¼ã‚¸ã¯redirectã§æŒ‡å®šã•ã‚ŒãŸå…ˆã«ç§»å‹• location.href = redirect; return; } diff --git a/src/client/init.ts b/src/client/init.ts index 654e176398ac3383130b8ed4cbf8f368b953682a..81d17f0d2749cc48a21c6cd8d9d35258ee5df89d 100644 --- a/src/client/init.ts +++ b/src/client/init.ts @@ -93,7 +93,10 @@ if (defaultStore.state.reportError && !_DEV_) { document.addEventListener('touchend', () => {}, { passive: true }); // 一斉リãƒãƒ¼ãƒ‰ -reloadChannel.addEventListener('message', () => location.reload()); +reloadChannel.addEventListener('message', path => { + if (path !== null) location.href = path; + else location.reload(); +}); //#region SEE: https://css-tricks.com/the-trick-to-viewport-units-on-mobile/ // TODO: ã„ã¤ã®æ—¥ã«ã‹æ¶ˆã—ãŸã„ diff --git a/src/client/scripts/unison-reload.ts b/src/client/scripts/unison-reload.ts index 92556aefaaa451619f066648dcaab3e83e386815..59af584c1b8b1054dcaf1f9bab631552a03bbc1f 100644 --- a/src/client/scripts/unison-reload.ts +++ b/src/client/scripts/unison-reload.ts @@ -1,10 +1,15 @@ // SafariãŒBroadcastChannel未実装ãªã®ã§ãƒ©ã‚¤ãƒ–ラリを使ㆠimport { BroadcastChannel } from 'broadcast-channel'; -export const reloadChannel = new BroadcastChannel<'reload'>('reload'); +export const reloadChannel = new BroadcastChannel<string | null>('reload'); // BroadcastChannelを用ã„ã¦ã€ã‚¯ãƒ©ã‚¤ã‚¢ãƒ³ãƒˆãŒä¸€æ–‰ã«reloadã™ã‚‹ã‚ˆã†ã«ã—ã¾ã™ã€‚ -export function unisonReload() { - reloadChannel.postMessage('reload'); - location.reload(); +export function unisonReload(path?: string) { + if (path !== undefined) { + reloadChannel.postMessage(path); + location.href = path; + } else { + reloadChannel.postMessage(null); + location.reload(); + } }