From 4c31eb409cd3b2655393ca0a946a1bf110d974f0 Mon Sep 17 00:00:00 2001 From: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sat, 20 Dec 2025 21:22:31 +0900 Subject: fix(frontend): ストレージが消去される事がある問題を軽減 (#16704) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(frontend): ストレージが消去される事がある問題を軽減 * add comment * add catch to continue request permissions * Update Changelog * update changelog * fix 通知権限の許可取得はボタン押下時に移動 * fix * wip * Update main-boot.ts * wip --------- Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com> --- packages/frontend/src/utility/storage.ts | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 packages/frontend/src/utility/storage.ts (limited to 'packages/frontend/src/utility') diff --git a/packages/frontend/src/utility/storage.ts b/packages/frontend/src/utility/storage.ts new file mode 100644 index 0000000000..9df3a251e6 --- /dev/null +++ b/packages/frontend/src/utility/storage.ts @@ -0,0 +1,34 @@ +/* + * SPDX-FileCopyrightText: syuilo and misskey-project + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import { computed, ref, shallowRef, watch, defineAsyncComponent } from 'vue'; +import * as os from '@/os.js'; +import { store } from '@/store.js'; +import { i18n } from '@/i18n.js'; + +export const storagePersisted = ref(await navigator.storage.persisted()); + +export async function enableStoragePersistence() { + try { + const persisted = await navigator.storage.persist(); + if (persisted) { + storagePersisted.value = true; + } else { + os.alert({ + type: 'error', + text: i18n.ts.somethingHappened, + }); + } + } catch (err) { + os.alert({ + type: 'error', + text: i18n.ts.somethingHappened, + }); + } +} + +export function skipStoragePersistence() { + store.set('showStoragePersistenceSuggestion', false); +} -- cgit v1.2.3-freya