From b67d3f88b6f8e6bfca97a6d56d6427313c285f68 Mon Sep 17 00:00:00 2001
From: tamaina <tamaina@hotmail.co.jp>
Date: Tue, 24 Aug 2021 14:18:19 +0900
Subject: [PATCH] Redirect to welcome page when sign out

---
 src/client/account.ts               |  2 +-
 src/client/init.ts                  |  5 ++++-
 src/client/scripts/unison-reload.ts | 13 +++++++++----
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/client/account.ts b/src/client/account.ts
index ee1d845493..326184c4b3 100644
--- a/src/client/account.ts
+++ b/src/client/account.ts
@@ -47,7 +47,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'] }[]> {
diff --git a/src/client/init.ts b/src/client/init.ts
index 4d2170e03f..4484cbb497 100644
--- a/src/client/init.ts
+++ b/src/client/init.ts
@@ -89,7 +89,10 @@ if (defaultStore.state.reportError && !_DEV_) {
 document.addEventListener('touchend', () => {}, { passive: true });
 
 // 一斉リロード
-reloadChannel.addEventListener('message', () => location.reload());
+reloadChannel.addEventListener('message', path => {
+	if (path === 'reload')
+	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..745a0a7a1d 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>('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('reload');
+		location.reload();
+	}
 }