fix: storagePersistenceのtop-level awaitを解消

This commit is contained in:
kakkokari-gtyih
2026-03-03 19:11:36 +09:00
parent 4d9f6e758c
commit f22d5ad683
2 changed files with 15 additions and 3 deletions

View File

@@ -30,6 +30,7 @@ import { fetchCustomEmojis } from '@/custom-emojis.js';
import { prefer } from '@/preferences.js';
import { $i } from '@/i.js';
import { launchPlugins } from '@/plugin.js';
import { initializeStoragePersistence } from '@/utility/storage.js';
export async function common(createVue: () => Promise<App<Element>>) {
console.info(`Misskey v${version}`);
@@ -327,6 +328,10 @@ export async function common(createVue: () => Promise<App<Element>>) {
console.error('Failed to launch plugins:', error);
}
// ブラウザストレージ永続化の状態を初期化
// top-level awaitを防ぐために明示的に起動時に確認する
initializeStoragePersistence();
app.mount(rootEl);
// boot.jsのやつを解除

View File

@@ -3,20 +3,27 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { ref } from 'vue';
import { readonly, ref } from 'vue';
import * as os from '@/os.js';
import { store } from '@/store.js';
import { i18n } from '@/i18n.js';
export const storagePersistenceSupported = window.isSecureContext && 'storage' in navigator;
export const storagePersisted = ref(storagePersistenceSupported ? await navigator.storage.persisted() : false);
const _storagePersisted = ref(false);
export const storagePersisted = readonly(_storagePersisted);
export async function initializeStoragePersistence() {
if (storagePersistenceSupported) {
_storagePersisted.value = await navigator.storage.persisted().catch(() => false);
}
}
export async function enableStoragePersistence() {
if (!storagePersistenceSupported) return;
try {
const persisted = await navigator.storage.persist();
if (persisted) {
storagePersisted.value = true;
_storagePersisted.value = true;
} else {
os.alert({
type: 'error',