From aca77b7af08f22a40d6e4442bcde48e02b928999 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Thu, 12 Sep 2024 19:16:45 +0900 Subject: [PATCH 1/6] =?UTF-8?q?fix(frontend):=20reloadAsk=E3=81=8C?= =?UTF-8?q?=E5=90=8C=E6=99=82=E3=81=AB=E8=A4=87=E6=95=B0=E5=AE=9F=E8=A1=8C?= =?UTF-8?q?=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frontend/src/pages/settings/general.vue | 17 ++++------- .../frontend/src/pages/settings/navbar.vue | 12 +------- .../frontend/src/pages/settings/other.vue | 12 +------- .../frontend/src/pages/settings/theme.vue | 12 +------- packages/frontend/src/scripts/reload-ask.ts | 29 +++++++++++++++++++ 5 files changed, 38 insertions(+), 44 deletions(-) create mode 100644 packages/frontend/src/scripts/reload-ask.ts diff --git a/packages/frontend/src/pages/settings/general.vue b/packages/frontend/src/pages/settings/general.vue index 15af5617cc5a..a9ab5e810633 100644 --- a/packages/frontend/src/pages/settings/general.vue +++ b/packages/frontend/src/pages/settings/general.vue @@ -258,7 +258,7 @@ import { langs } from '@@/js/config.js'; import { defaultStore } from '@/store.js'; import * as os from '@/os.js'; import { misskeyApi } from '@/scripts/misskey-api.js'; -import { unisonReload } from '@/scripts/unison-reload.js'; +import { reloadAsk } from '@/scripts/reload-ask.js'; import { i18n } from '@/i18n.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { miLocalStorage } from '@/local-storage.js'; @@ -270,16 +270,6 @@ const fontSize = ref(miLocalStorage.getItem('fontSize')); const useSystemFont = ref(miLocalStorage.getItem('useSystemFont') != null); const dataSaver = ref(defaultStore.state.dataSaver); -async function reloadAsk() { - const { canceled } = await os.confirm({ - type: 'info', - text: i18n.ts.reloadToApplySetting, - }); - if (canceled) return; - - unisonReload(); -} - const hemisphere = computed(defaultStore.makeGetterSetter('hemisphere')); const overridedDeviceKind = computed(defaultStore.makeGetterSetter('overridedDeviceKind')); const serverDisconnectedBehavior = computed(defaultStore.makeGetterSetter('serverDisconnectedBehavior')); @@ -347,6 +337,8 @@ watch(useSystemFont, () => { } }); +const isReloadConfirming = ref(false); + watch([ hemisphere, lang, @@ -369,7 +361,10 @@ watch([ confirmWhenRevealingSensitiveMedia, contextMenu, ], async () => { + if (isReloadConfirming.value) return; + isReloadConfirming.value = true; await reloadAsk(); + isReloadConfirming.value = false; }); const emojiIndexLangs = ['en-US', 'ja-JP', 'ja-JP_hira'] as const; diff --git a/packages/frontend/src/pages/settings/navbar.vue b/packages/frontend/src/pages/settings/navbar.vue index 7f8460e31640..ca63cff9acd2 100644 --- a/packages/frontend/src/pages/settings/navbar.vue +++ b/packages/frontend/src/pages/settings/navbar.vue @@ -54,7 +54,7 @@ import MkContainer from '@/components/MkContainer.vue'; import * as os from '@/os.js'; import { navbarItemDef } from '@/navbar.js'; import { defaultStore } from '@/store.js'; -import { unisonReload } from '@/scripts/unison-reload.js'; +import { reloadAsk } from '@/scripts/reload-ask.js'; import { i18n } from '@/i18n.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; @@ -67,16 +67,6 @@ const items = ref(defaultStore.state.menu.map(x => ({ const menuDisplay = computed(defaultStore.makeGetterSetter('menuDisplay')); -async function reloadAsk() { - const { canceled } = await os.confirm({ - type: 'info', - text: i18n.ts.reloadToApplySetting, - }); - if (canceled) return; - - unisonReload(); -} - async function addItem() { const menu = Object.keys(navbarItemDef).filter(k => !defaultStore.state.menu.includes(k)); const { canceled, result: item } = await os.select({ diff --git a/packages/frontend/src/pages/settings/other.vue b/packages/frontend/src/pages/settings/other.vue index a1cb2ea1c428..089f022a8021 100644 --- a/packages/frontend/src/pages/settings/other.vue +++ b/packages/frontend/src/pages/settings/other.vue @@ -98,7 +98,7 @@ import { defaultStore } from '@/store.js'; import { signout, signinRequired } from '@/account.js'; import { i18n } from '@/i18n.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; -import { unisonReload } from '@/scripts/unison-reload.js'; +import { reloadAsk } from '@/scripts/reload-ask.js'; import FormSection from '@/components/form/section.vue'; const $i = signinRequired(); @@ -132,16 +132,6 @@ async function deleteAccount() { await signout(); } -async function reloadAsk() { - const { canceled } = await os.confirm({ - type: 'info', - text: i18n.ts.reloadToApplySetting, - }); - if (canceled) return; - - unisonReload(); -} - async function updateRepliesAll(withReplies: boolean) { const { canceled } = await os.confirm({ type: 'warning', diff --git a/packages/frontend/src/pages/settings/theme.vue b/packages/frontend/src/pages/settings/theme.vue index 7d192bcbea6e..6cd70c69e049 100644 --- a/packages/frontend/src/pages/settings/theme.vue +++ b/packages/frontend/src/pages/settings/theme.vue @@ -88,19 +88,9 @@ import { uniqueBy } from '@/scripts/array.js'; import { fetchThemes, getThemes } from '@/theme-store.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; import { miLocalStorage } from '@/local-storage.js'; -import { unisonReload } from '@/scripts/unison-reload.js'; +import { reloadAsk } from '@/scripts/reload-ask.js'; import * as os from '@/os.js'; -async function reloadAsk() { - const { canceled } = await os.confirm({ - type: 'info', - text: i18n.ts.reloadToApplySetting, - }); - if (canceled) return; - - unisonReload(); -} - const installedThemes = ref(getThemes()); const builtinThemes = getBuiltinThemesRef(); diff --git a/packages/frontend/src/scripts/reload-ask.ts b/packages/frontend/src/scripts/reload-ask.ts new file mode 100644 index 000000000000..a45adb638cb1 --- /dev/null +++ b/packages/frontend/src/scripts/reload-ask.ts @@ -0,0 +1,29 @@ +/* + * SPDX-FileCopyrightText: syuilo and misskey-project + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import { i18n } from '@/i18n.js'; +import * as os from '@/os.js'; +import { unisonReload } from '@/scripts/unison-reload.js'; + +let isReloadConfirming = false; + +export async function reloadAsk() { + if (isReloadConfirming) { + return; + } + + isReloadConfirming = true; + + const { canceled } = await os.confirm({ + type: 'info', + text: i18n.ts.reloadToApplySetting, + }); + + if (!canceled) { + unisonReload(); + } + + isReloadConfirming = false; +} From 336373ad555ed1645234d77f741f02f71152d527 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Thu, 12 Sep 2024 19:19:03 +0900 Subject: [PATCH 2/6] Update Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d7425d4638d..a7b5ba297f84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Enhance: サイズ制限を超過するファイルをアップロードしようとした際にエラーを出すように - Enhance: アイコンデコレーション管理画面にプレビューを追加 - Fix: サーバーメトリクスが2つ以上あるとリロード直後の表示がおかしくなる問題を修正 +- Fix: 設定変更時のリロード確認ダイアログが複数個表示されることがある問題を修正 ### Server - Fix: ファイルがサイズの制限を超えてアップロードされた際にエラーを返さなかった問題を修正 From 7635439b6bf08f1a49fa55dd931fe692d31a76f3 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Thu, 12 Sep 2024 19:19:59 +0900 Subject: [PATCH 3/6] fix --- packages/frontend/src/pages/settings/general.vue | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/frontend/src/pages/settings/general.vue b/packages/frontend/src/pages/settings/general.vue index a9ab5e810633..8e5e37dc2de4 100644 --- a/packages/frontend/src/pages/settings/general.vue +++ b/packages/frontend/src/pages/settings/general.vue @@ -337,8 +337,6 @@ watch(useSystemFont, () => { } }); -const isReloadConfirming = ref(false); - watch([ hemisphere, lang, @@ -361,10 +359,7 @@ watch([ confirmWhenRevealingSensitiveMedia, contextMenu, ], async () => { - if (isReloadConfirming.value) return; - isReloadConfirming.value = true; await reloadAsk(); - isReloadConfirming.value = false; }); const emojiIndexLangs = ['en-US', 'ja-JP', 'ja-JP_hira'] as const; From b02aba840482ddc52686cdd963f7b9df992b62eb Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Thu, 12 Sep 2024 19:22:54 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=E3=83=95=E3=83=A9=E3=82=B0=E8=A7=A3?= =?UTF-8?q?=E9=99=A4=E3=81=8C=E7=A2=BA=E5=AE=9F=E3=81=AB=E8=A1=8C=E3=82=8F?= =?UTF-8?q?=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/scripts/reload-ask.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/frontend/src/scripts/reload-ask.ts b/packages/frontend/src/scripts/reload-ask.ts index a45adb638cb1..cf90e6676e22 100644 --- a/packages/frontend/src/scripts/reload-ask.ts +++ b/packages/frontend/src/scripts/reload-ask.ts @@ -19,11 +19,11 @@ export async function reloadAsk() { const { canceled } = await os.confirm({ type: 'info', text: i18n.ts.reloadToApplySetting, + }).finally(() => { + isReloadConfirming = false; }); - if (!canceled) { - unisonReload(); - } + if (canceled) return; - isReloadConfirming = false; + unisonReload(); } From 215f7f082620338246e7657c6ea2f48da72d823e Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sun, 15 Sep 2024 17:09:13 +0900 Subject: [PATCH 5/6] =?UTF-8?q?reloadAsk=E3=82=92=E6=B1=8E=E7=94=A8?= =?UTF-8?q?=E5=8C=96=E3=80=81=E7=90=86=E7=94=B1=E3=82=92=E5=8F=97=E3=81=91?= =?UTF-8?q?=E5=8F=96=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/index.d.ts | 2 +- locales/ja-JP.yml | 2 +- .../frontend/src/pages/settings/general.vue | 2 +- .../frontend/src/pages/settings/navbar.vue | 4 ++-- .../frontend/src/pages/settings/other.vue | 2 +- .../frontend/src/pages/settings/theme.vue | 2 +- packages/frontend/src/scripts/reload-ask.ts | 19 +++++++++++++++---- 7 files changed, 22 insertions(+), 11 deletions(-) diff --git a/locales/index.d.ts b/locales/index.d.ts index fecc5703950d..b06e0f245b19 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -3121,7 +3121,7 @@ export interface Locale extends ILocale { */ "narrow": string; /** - * 設定はページリロード後に反映されます。今すぐリロードしますか? + * 設定はページリロード後に反映されます。 */ "reloadToApplySetting": string; /** diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index a1210bad2948..d8a6f5591372 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -776,7 +776,7 @@ left: "左" center: "中央" wide: "広い" narrow: "狭い" -reloadToApplySetting: "設定はページリロード後に反映されます。今すぐリロードしますか?" +reloadToApplySetting: "設定はページリロード後に反映されます。" needReloadToApply: "反映には再起動が必要です。" showTitlebar: "タイトルバーを表示する" clearCache: "キャッシュをクリア" diff --git a/packages/frontend/src/pages/settings/general.vue b/packages/frontend/src/pages/settings/general.vue index 8e5e37dc2de4..69238b043693 100644 --- a/packages/frontend/src/pages/settings/general.vue +++ b/packages/frontend/src/pages/settings/general.vue @@ -359,7 +359,7 @@ watch([ confirmWhenRevealingSensitiveMedia, contextMenu, ], async () => { - await reloadAsk(); + await reloadAsk({ reason: i18n.ts.reloadToApplySetting, unison: true }); }); const emojiIndexLangs = ['en-US', 'ja-JP', 'ja-JP_hira'] as const; diff --git a/packages/frontend/src/pages/settings/navbar.vue b/packages/frontend/src/pages/settings/navbar.vue index ca63cff9acd2..a0e6cad9c8d4 100644 --- a/packages/frontend/src/pages/settings/navbar.vue +++ b/packages/frontend/src/pages/settings/navbar.vue @@ -90,7 +90,7 @@ function removeItem(index: number) { async function save() { defaultStore.set('menu', items.value.map(x => x.type)); - await reloadAsk(); + await reloadAsk({ reason: i18n.ts.reloadToApplySetting, unison: true }); } function reset() { @@ -101,7 +101,7 @@ function reset() { } watch(menuDisplay, async () => { - await reloadAsk(); + await reloadAsk({ reason: i18n.ts.reloadToApplySetting, unison: true }); }); const headerActions = computed(() => []); diff --git a/packages/frontend/src/pages/settings/other.vue b/packages/frontend/src/pages/settings/other.vue index 089f022a8021..0f7609c83e95 100644 --- a/packages/frontend/src/pages/settings/other.vue +++ b/packages/frontend/src/pages/settings/other.vue @@ -145,7 +145,7 @@ async function updateRepliesAll(withReplies: boolean) { watch([ enableCondensedLineForAcct, ], async () => { - await reloadAsk(); + await reloadAsk({ reason: i18n.ts.reloadToApplySetting, unison: true }); }); const headerActions = computed(() => []); diff --git a/packages/frontend/src/pages/settings/theme.vue b/packages/frontend/src/pages/settings/theme.vue index 6cd70c69e049..6bd51754d6f9 100644 --- a/packages/frontend/src/pages/settings/theme.vue +++ b/packages/frontend/src/pages/settings/theme.vue @@ -144,7 +144,7 @@ watch(wallpaper, () => { } else { miLocalStorage.setItem('wallpaper', wallpaper.value); } - reloadAsk(); + await reloadAsk({ reason: i18n.ts.reloadToApplySetting, unison: true }); }); onActivated(() => { diff --git a/packages/frontend/src/scripts/reload-ask.ts b/packages/frontend/src/scripts/reload-ask.ts index cf90e6676e22..733d91b85ab4 100644 --- a/packages/frontend/src/scripts/reload-ask.ts +++ b/packages/frontend/src/scripts/reload-ask.ts @@ -9,21 +9,32 @@ import { unisonReload } from '@/scripts/unison-reload.js'; let isReloadConfirming = false; -export async function reloadAsk() { +export async function reloadAsk(opts: { + unison?: boolean; + reason?: string; +}) { if (isReloadConfirming) { return; } isReloadConfirming = true; - const { canceled } = await os.confirm({ + const { canceled } = await os.confirm(opts.reason == null ? { type: 'info', - text: i18n.ts.reloadToApplySetting, + text: i18n.ts.reloadConfirm, + } : { + type: 'info', + title: i18n.ts.reloadConfirm, + text: opts.reason, }).finally(() => { isReloadConfirming = false; }); if (canceled) return; - unisonReload(); + if (opts.unison) { + unisonReload(); + } else { + location.reload(); + } } From f70bfbec791902254a5bfcfdd153e8a76932cbe9 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sun, 15 Sep 2024 17:11:44 +0900 Subject: [PATCH 6/6] fix --- packages/frontend/src/pages/settings/theme.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/frontend/src/pages/settings/theme.vue b/packages/frontend/src/pages/settings/theme.vue index 6bd51754d6f9..ce8ec686928a 100644 --- a/packages/frontend/src/pages/settings/theme.vue +++ b/packages/frontend/src/pages/settings/theme.vue @@ -138,7 +138,7 @@ watch(syncDeviceDarkMode, () => { } }); -watch(wallpaper, () => { +watch(wallpaper, async () => { if (wallpaper.value == null) { miLocalStorage.removeItem('wallpaper'); } else {