2021-02-14 13:23:36 +01:00
|
|
|
// SafariがBroadcastChannel未実装なのでライブラリを使う
|
|
|
|
import { BroadcastChannel } from 'broadcast-channel';
|
|
|
|
|
2021-02-21 06:35:54 +01:00
|
|
|
export const reloadChannel = new BroadcastChannel<boolean>('reload');
|
2021-02-14 13:23:36 +01:00
|
|
|
|
|
|
|
// BroadcastChannelを用いて、クライアントが一斉にreloadするようにします。
|
2021-02-21 06:35:54 +01:00
|
|
|
export function unisonReload(redirectToRoot?: boolean) {
|
|
|
|
reloadChannel.postMessage(!!redirectToRoot);
|
|
|
|
reload();
|
|
|
|
}
|
|
|
|
|
|
|
|
export function reload(redirectToRoot?: boolean) {
|
|
|
|
if (redirectToRoot) {
|
|
|
|
location.href = '/';
|
|
|
|
} else {
|
|
|
|
location.reload();
|
|
|
|
}
|
2021-02-14 13:23:36 +01:00
|
|
|
}
|