summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortamaina <tamaina@hotmail.co.jp>2021-11-05 00:09:13 +0900
committerGitHub <noreply@github.com>2021-11-05 00:09:13 +0900
commite2862ed097a7de54a1a617f55dffee52a00010fc (patch)
treeeed0249ced2af7bf85688649d9f6a1a88b9be772 /src
parentrefactor: Introduce list of MFM Functions (#7882) (diff)
downloadsharkey-e2862ed097a7de54a1a617f55dffee52a00010fc.tar.gz
sharkey-e2862ed097a7de54a1a617f55dffee52a00010fc.tar.bz2
sharkey-e2862ed097a7de54a1a617f55dffee52a00010fc.zip
enhane: 完全ログアウト時にすべてのタブがウェルカムページへ移動するように (#7928)
* enhane: unison-reloadに指定したパスに移動できるように * null * null * null * add comments
Diffstat (limited to 'src')
-rw-r--r--src/client/account.ts6
-rw-r--r--src/client/init.ts5
-rw-r--r--src/client/scripts/unison-reload.ts13
3 files changed, 17 insertions, 7 deletions
diff --git a/src/client/account.ts b/src/client/account.ts
index a3fe082a22..a2165ebed1 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 654e176398..81d17f0d27 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 92556aefaa..59af584c1b 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();
+ }
}