enhane: 完全ログアウト時にすべてのタブがウェルカムページへ移動するように (#7928)

* enhane: unison-reloadに指定したパスに移動できるように

* null

* null

* null

* add comments
This commit is contained in:
tamaina 2021-11-05 00:09:13 +09:00 committed by GitHub
parent 1c38c7010d
commit e2862ed097
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 7 deletions

View file

@ -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();
}
}