reloadAskを汎用化、理由を受け取るように

This commit is contained in:
kakkokari-gtyih 2024-09-15 17:09:13 +09:00
parent 1603ce980d
commit 215f7f0826
7 changed files with 22 additions and 11 deletions

2
locales/index.d.ts vendored
View File

@ -3121,7 +3121,7 @@ export interface Locale extends ILocale {
*/ */
"narrow": string; "narrow": string;
/** /**
* *
*/ */
"reloadToApplySetting": string; "reloadToApplySetting": string;
/** /**

View File

@ -776,7 +776,7 @@ left: "左"
center: "中央" center: "中央"
wide: "広い" wide: "広い"
narrow: "狭い" narrow: "狭い"
reloadToApplySetting: "設定はページリロード後に反映されます。今すぐリロードしますか?" reloadToApplySetting: "設定はページリロード後に反映されます。"
needReloadToApply: "反映には再起動が必要です。" needReloadToApply: "反映には再起動が必要です。"
showTitlebar: "タイトルバーを表示する" showTitlebar: "タイトルバーを表示する"
clearCache: "キャッシュをクリア" clearCache: "キャッシュをクリア"

View File

@ -359,7 +359,7 @@ watch([
confirmWhenRevealingSensitiveMedia, confirmWhenRevealingSensitiveMedia,
contextMenu, contextMenu,
], async () => { ], async () => {
await reloadAsk(); await reloadAsk({ reason: i18n.ts.reloadToApplySetting, unison: true });
}); });
const emojiIndexLangs = ['en-US', 'ja-JP', 'ja-JP_hira'] as const; const emojiIndexLangs = ['en-US', 'ja-JP', 'ja-JP_hira'] as const;

View File

@ -90,7 +90,7 @@ function removeItem(index: number) {
async function save() { async function save() {
defaultStore.set('menu', items.value.map(x => x.type)); defaultStore.set('menu', items.value.map(x => x.type));
await reloadAsk(); await reloadAsk({ reason: i18n.ts.reloadToApplySetting, unison: true });
} }
function reset() { function reset() {
@ -101,7 +101,7 @@ function reset() {
} }
watch(menuDisplay, async () => { watch(menuDisplay, async () => {
await reloadAsk(); await reloadAsk({ reason: i18n.ts.reloadToApplySetting, unison: true });
}); });
const headerActions = computed(() => []); const headerActions = computed(() => []);

View File

@ -145,7 +145,7 @@ async function updateRepliesAll(withReplies: boolean) {
watch([ watch([
enableCondensedLineForAcct, enableCondensedLineForAcct,
], async () => { ], async () => {
await reloadAsk(); await reloadAsk({ reason: i18n.ts.reloadToApplySetting, unison: true });
}); });
const headerActions = computed(() => []); const headerActions = computed(() => []);

View File

@ -144,7 +144,7 @@ watch(wallpaper, () => {
} else { } else {
miLocalStorage.setItem('wallpaper', wallpaper.value); miLocalStorage.setItem('wallpaper', wallpaper.value);
} }
reloadAsk(); await reloadAsk({ reason: i18n.ts.reloadToApplySetting, unison: true });
}); });
onActivated(() => { onActivated(() => {

View File

@ -9,21 +9,32 @@ import { unisonReload } from '@/scripts/unison-reload.js';
let isReloadConfirming = false; let isReloadConfirming = false;
export async function reloadAsk() { export async function reloadAsk(opts: {
unison?: boolean;
reason?: string;
}) {
if (isReloadConfirming) { if (isReloadConfirming) {
return; return;
} }
isReloadConfirming = true; isReloadConfirming = true;
const { canceled } = await os.confirm({ const { canceled } = await os.confirm(opts.reason == null ? {
type: 'info', type: 'info',
text: i18n.ts.reloadToApplySetting, text: i18n.ts.reloadConfirm,
} : {
type: 'info',
title: i18n.ts.reloadConfirm,
text: opts.reason,
}).finally(() => { }).finally(() => {
isReloadConfirming = false; isReloadConfirming = false;
}); });
if (canceled) return; if (canceled) return;
if (opts.unison) {
unisonReload(); unisonReload();
} else {
location.reload();
}
} }