1
0
forked from mirror/misskey
misskey/packages/client/src/scripts/unison-reload.ts

15 lines
433 B
TypeScript
Raw Normal View History

2022-04-28 02:57:59 +09:00
import { BroadcastChannel } from 'broadcast-channel';
export const reloadChannel = new BroadcastChannel<string | null>('reload');
// BroadcastChannelを用いて、クライアントが一斉にreloadするようにします。
export function unisonReload(path?: string) {
if (path !== undefined) {
reloadChannel.postMessage(path);
location.href = path;
} else {
reloadChannel.postMessage(null);
location.reload();
}
}