mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-03-21 11:40:49 +00:00
fix: storagePersistenceのtop-level awaitを解消
This commit is contained in:
@@ -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のやつを解除
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user