2023-07-27 08:31:52 +03:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2022-11-24 11:27:05 +02:00
|
|
|
// SafariがBroadcastChannel未実装なのでライブラリを使う
|
2022-04-27 20:57:59 +03:00
|
|
|
import { BroadcastChannel } from 'broadcast-channel';
|
|
|
|
|
|
|
|
export const reloadChannel = new BroadcastChannel<string | null>('reload');
|
2021-02-17 14:36:56 +02:00
|
|
|
|
|
|
|
// BroadcastChannelを用いて、クライアントが一斉にreloadするようにします。
|
2021-11-04 17:09:13 +02:00
|
|
|
export function unisonReload(path?: string) {
|
|
|
|
if (path !== undefined) {
|
|
|
|
reloadChannel.postMessage(path);
|
|
|
|
location.href = path;
|
|
|
|
} else {
|
|
|
|
reloadChannel.postMessage(null);
|
|
|
|
location.reload();
|
|
|
|
}
|
2021-02-17 14:36:56 +02:00
|
|
|
}
|