summaryrefslogtreecommitdiff
path: root/packages/frontend/src/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/frontend/src/scripts')
-rw-r--r--packages/frontend/src/scripts/reload-ask.ts40
1 files changed, 40 insertions, 0 deletions
diff --git a/packages/frontend/src/scripts/reload-ask.ts b/packages/frontend/src/scripts/reload-ask.ts
new file mode 100644
index 0000000000..733d91b85a
--- /dev/null
+++ b/packages/frontend/src/scripts/reload-ask.ts
@@ -0,0 +1,40 @@
+/*
+ * 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(opts: {
+ unison?: boolean;
+ reason?: string;
+}) {
+ if (isReloadConfirming) {
+ return;
+ }
+
+ isReloadConfirming = true;
+
+ const { canceled } = await os.confirm(opts.reason == null ? {
+ type: 'info',
+ text: i18n.ts.reloadConfirm,
+ } : {
+ type: 'info',
+ title: i18n.ts.reloadConfirm,
+ text: opts.reason,
+ }).finally(() => {
+ isReloadConfirming = false;
+ });
+
+ if (canceled) return;
+
+ if (opts.unison) {
+ unisonReload();
+ } else {
+ location.reload();
+ }
+}