From 412db316cca5dbe28835c0c089ba8897f5dfafea Mon Sep 17 00:00:00 2001 From: tamaina Date: Sun, 14 Feb 2021 21:23:36 +0900 Subject: [PATCH] Resolve #6804 Implement unison reload --- package.json | 1 + src/client/account.ts | 3 +- src/client/pages/settings/deck.vue | 5 +- src/client/pages/settings/general.vue | 3 +- src/client/pages/settings/index.vue | 3 +- src/client/pages/settings/other.vue | 3 +- src/client/pages/settings/plugin.install.vue | 3 +- src/client/pages/settings/plugin.manage.vue | 2 +- src/client/pages/share.vue | 2 + src/client/scripts/unison-reload.ts | 12 +++++ src/client/sidebar.ts | 7 +-- yarn.lock | 57 +++++++++++++++++++- 12 files changed, 89 insertions(+), 12 deletions(-) create mode 100644 src/client/scripts/unison-reload.ts diff --git a/package.json b/package.json index 927f28dc7a..6a4dbdc6a9 100644 --- a/package.json +++ b/package.json @@ -117,6 +117,7 @@ "aws-sdk": "2.840.0", "bcryptjs": "2.4.3", "blurhash": "1.1.3", + "broadcast-channel": "3.4.1", "bull": "3.20.1", "cafy": "15.2.1", "cbor": "6.0.1", diff --git a/src/client/account.ts b/src/client/account.ts index 05faeb3220..e5b451cf14 100644 --- a/src/client/account.ts +++ b/src/client/account.ts @@ -1,6 +1,7 @@ import { reactive } from 'vue'; import { apiUrl } from '@/config'; import { waiting } from '@/os'; +import { unisonReload } from '@/scripts/unison-reload'; // TODO: 他のタブと永続化されたstateを同期 @@ -75,7 +76,7 @@ export async function login(token: Account['token']) { const me = await fetchAccount(token); localStorage.setItem('account', JSON.stringify(me)); addAccount(me.id, token); - location.reload(); + unisonReload(); } // このファイルに書きたくないけどここに書かないと何故かVeturが認識しない diff --git a/src/client/pages/settings/deck.vue b/src/client/pages/settings/deck.vue index 30d36d4a06..cbc5edca94 100644 --- a/src/client/pages/settings/deck.vue +++ b/src/client/pages/settings/deck.vue @@ -40,6 +40,7 @@ import FormBase from '@/components/form/base.vue'; import FormGroup from '@/components/form/group.vue'; import { deckStore } from '@/ui/deck/deck-store'; import * as os from '@/os'; +import { unisonReload } from '@/scripts/unison-reload'; export default defineComponent({ components: { @@ -81,7 +82,7 @@ export default defineComponent({ }); if (canceled) return; - location.reload(); + unisonReload(); } }, @@ -99,7 +100,7 @@ export default defineComponent({ }); if (canceled) return; this.profile = name; - location.reload(); + unisonReload(); } } }); diff --git a/src/client/pages/settings/general.vue b/src/client/pages/settings/general.vue index 9314e14dab..0e741d474c 100644 --- a/src/client/pages/settings/general.vue +++ b/src/client/pages/settings/general.vue @@ -96,6 +96,7 @@ import { langs } from '@/config'; import { defaultStore } from '@/store'; import { ColdDeviceStorage } from '@/store'; import * as os from '@/os'; +import { unisonReload } from '@/scripts/unison-reload'; export default defineComponent({ components: { @@ -200,7 +201,7 @@ export default defineComponent({ }); if (canceled) return; - location.reload(); + unisonReload(); } } }); diff --git a/src/client/pages/settings/index.vue b/src/client/pages/settings/index.vue index df53eb5133..32cbce2f96 100644 --- a/src/client/pages/settings/index.vue +++ b/src/client/pages/settings/index.vue @@ -52,6 +52,7 @@ import FormBase from '@/components/form/base.vue'; import FormButton from '@/components/form/button.vue'; import { scroll } from '@/scripts/scroll'; import { signout } from '@/account'; +import { unisonReload } from '@/scripts/unison-reload'; export default defineComponent({ components: { @@ -159,7 +160,7 @@ export default defineComponent({ clear: () => { localStorage.removeItem('locale'); localStorage.removeItem('theme'); - location.reload(); + unisonReload(); }, faPalette, faPlug, faUser, faListUl, faLock, faLaugh, faCommentSlash, faMusic, faBell, faCogs, faEllipsisH, faBan, faShareAlt, faLockOpen, faKey, faBoxes, faEnvelope, faCloud, }; diff --git a/src/client/pages/settings/other.vue b/src/client/pages/settings/other.vue index c6ec9f6c0a..c0b9625098 100644 --- a/src/client/pages/settings/other.vue +++ b/src/client/pages/settings/other.vue @@ -40,6 +40,7 @@ import * as os from '@/os'; import { debug } from '@/config'; import { defaultStore } from '@/store'; import { signout } from '@/account'; +import { unisonReload } from '@/scripts/unison-reload'; export default defineComponent({ components: { @@ -76,7 +77,7 @@ export default defineComponent({ changeDebug(v) { console.log(v); localStorage.setItem('debug', v.toString()); - location.reload(); + unisonReload(); }, onChangeInjectFeaturedNote(v) { diff --git a/src/client/pages/settings/plugin.install.vue b/src/client/pages/settings/plugin.install.vue index 34c62619ad..e78ce06aa5 100644 --- a/src/client/pages/settings/plugin.install.vue +++ b/src/client/pages/settings/plugin.install.vue @@ -28,6 +28,7 @@ import FormButton from '@/components/form/button.vue'; import MkInfo from '@/components/ui/info.vue'; import * as os from '@/os'; import { ColdDeviceStorage } from '@/store'; +import { unisonReload } from '@/scripts/unison-reload'; export default defineComponent({ components: { @@ -138,7 +139,7 @@ export default defineComponent({ os.success(); this.$nextTick(() => { - location.reload(); + unisonReload(); }); }, } diff --git a/src/client/pages/settings/plugin.manage.vue b/src/client/pages/settings/plugin.manage.vue index 88eeef2bb2..5fd93d8b72 100644 --- a/src/client/pages/settings/plugin.manage.vue +++ b/src/client/pages/settings/plugin.manage.vue @@ -76,7 +76,7 @@ export default defineComponent({ ColdDeviceStorage.set('plugins', this.plugins.filter(x => x.id !== plugin.id)); os.success(); this.$nextTick(() => { - location.reload(); + unisonReload(); }); }, diff --git a/src/client/pages/share.vue b/src/client/pages/share.vue index 7912e5421f..e201caba77 100644 --- a/src/client/pages/share.vue +++ b/src/client/pages/share.vue @@ -12,6 +12,8 @@