From 060a6544078a6bf1b18411a8104e9d6d5239382f Mon Sep 17 00:00:00 2001 From: adzukimame <88547072+adzuki02@users.noreply.github.com> Date: Sun, 8 Dec 2024 14:20:06 +0900 Subject: [PATCH] =?UTF-8?q?LeaveGuard=E3=82=92=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/pages/theme-editor.vue | 7 +-- .../frontend/src/scripts/use-leave-guard.ts | 50 ------------------- 2 files changed, 1 insertion(+), 56 deletions(-) delete mode 100644 packages/frontend/src/scripts/use-leave-guard.ts diff --git a/packages/frontend/src/pages/theme-editor.vue b/packages/frontend/src/pages/theme-editor.vue index a6dbd3150289..a66871cd133f 100644 --- a/packages/frontend/src/pages/theme-editor.vue +++ b/packages/frontend/src/pages/theme-editor.vue @@ -93,7 +93,6 @@ import * as os from '@/os.js'; import { ColdDeviceStorage, defaultStore } from '@/store.js'; import { addTheme } from '@/theme-store.js'; import { i18n } from '@/i18n.js'; -import { useLeaveGuard } from '@/scripts/use-leave-guard.js'; import { definePageMetadata } from '@/scripts/page-metadata.js'; const $i = signinRequired(); @@ -133,9 +132,6 @@ const theme = ref & Partial>({ }); const description = ref(null); const themeCode = ref(null); -const changed = ref(false); - -useLeaveGuard(changed); function showPreview() { os.pageWindow('/preview'); @@ -170,7 +166,6 @@ function setFgColor(color) { function apply() { themeCode.value = JSON5.stringify(theme.value, null, '\t'); applyTheme(theme.value as Theme, false); - changed.value = true; } function applyThemeCode() { @@ -211,7 +206,7 @@ async function saveAs() { } else { ColdDeviceStorage.set('lightTheme', theme.value as Theme); } - changed.value = false; + os.alert({ type: 'success', text: i18n.tsx._theme.installed({ name: theme.value.name }), diff --git a/packages/frontend/src/scripts/use-leave-guard.ts b/packages/frontend/src/scripts/use-leave-guard.ts deleted file mode 100644 index 395c12a756ae..000000000000 --- a/packages/frontend/src/scripts/use-leave-guard.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SPDX-FileCopyrightText: syuilo and misskey-project - * SPDX-License-Identifier: AGPL-3.0-only - */ - -import type { Ref } from 'vue'; - -export function useLeaveGuard(enabled: Ref) { - /* TODO - const setLeaveGuard = inject('setLeaveGuard'); - - if (setLeaveGuard) { - setLeaveGuard(async () => { - if (!enabled.value) return false; - - const { canceled } = await os.confirm({ - type: 'warning', - text: i18n.ts.leaveConfirm, - }); - - return canceled; - }); - } else { - onBeforeRouteLeave(async (to, from) => { - if (!enabled.value) return true; - - const { canceled } = await os.confirm({ - type: 'warning', - text: i18n.ts.leaveConfirm, - }); - - return !canceled; - }); - } - */ - - /* - function onBeforeLeave(ev: BeforeUnloadEvent) { - if (enabled.value) { - ev.preventDefault(); - ev.returnValue = ''; - } - } - - window.addEventListener('beforeunload', onBeforeLeave); - onUnmounted(() => { - window.removeEventListener('beforeunload', onBeforeLeave); - }); - */ -}