Skip to content

Commit

Permalink
reloadAskを汎用化、理由を受け取るように
Browse files Browse the repository at this point in the history
  • Loading branch information
kakkokari-gtyih committed Sep 15, 2024
1 parent 1603ce9 commit 215f7f0
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3121,7 +3121,7 @@ export interface Locale extends ILocale {
*/
"narrow": string;
/**
* 設定はページリロード後に反映されます。今すぐリロードしますか?
* 設定はページリロード後に反映されます。
*/
"reloadToApplySetting": string;
/**
Expand Down
2 changes: 1 addition & 1 deletion locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ left: "左"
center: "中央"
wide: "広い"
narrow: "狭い"
reloadToApplySetting: "設定はページリロード後に反映されます。今すぐリロードしますか?"
reloadToApplySetting: "設定はページリロード後に反映されます。"
needReloadToApply: "反映には再起動が必要です。"
showTitlebar: "タイトルバーを表示する"
clearCache: "キャッシュをクリア"
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/settings/general.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/frontend/src/pages/settings/navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -101,7 +101,7 @@ function reset() {
}

watch(menuDisplay, async () => {
await reloadAsk();
await reloadAsk({ reason: i18n.ts.reloadToApplySetting, unison: true });
});

const headerActions = computed(() => []);
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/settings/other.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => []);
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/src/pages/settings/theme.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ watch(wallpaper, () => {
} else {
miLocalStorage.setItem('wallpaper', wallpaper.value);
}
reloadAsk();
await reloadAsk({ reason: i18n.ts.reloadToApplySetting, unison: true });
});

onActivated(() => {
Expand Down
19 changes: 15 additions & 4 deletions packages/frontend/src/scripts/reload-ask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit 215f7f0

Please sign in to comment.