mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-22 10:34:13 +02: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 { prefer } from '@/preferences.js';
|
||||||
import { $i } from '@/i.js';
|
import { $i } from '@/i.js';
|
||||||
import { launchPlugins } from '@/plugin.js';
|
import { launchPlugins } from '@/plugin.js';
|
||||||
|
import { initializeStoragePersistence } from '@/utility/storage.js';
|
||||||
|
|
||||||
export async function common(createVue: () => Promise<App<Element>>) {
|
export async function common(createVue: () => Promise<App<Element>>) {
|
||||||
console.info(`Misskey v${version}`);
|
console.info(`Misskey v${version}`);
|
||||||
@@ -327,6 +328,10 @@ export async function common(createVue: () => Promise<App<Element>>) {
|
|||||||
console.error('Failed to launch plugins:', error);
|
console.error('Failed to launch plugins:', error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ブラウザストレージ永続化の状態を初期化
|
||||||
|
// (top-level awaitを防ぐために明示的に起動時に確認する)
|
||||||
|
initializeStoragePersistence();
|
||||||
|
|
||||||
app.mount(rootEl);
|
app.mount(rootEl);
|
||||||
|
|
||||||
// boot.jsのやつを解除
|
// boot.jsのやつを解除
|
||||||
|
|||||||
@@ -3,20 +3,27 @@
|
|||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ref } from 'vue';
|
import { readonly, ref } from 'vue';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import { store } from '@/store.js';
|
import { store } from '@/store.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
|
|
||||||
export const storagePersistenceSupported = window.isSecureContext && 'storage' in navigator;
|
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() {
|
export async function enableStoragePersistence() {
|
||||||
if (!storagePersistenceSupported) return;
|
if (!storagePersistenceSupported) return;
|
||||||
try {
|
try {
|
||||||
const persisted = await navigator.storage.persist();
|
const persisted = await navigator.storage.persist();
|
||||||
if (persisted) {
|
if (persisted) {
|
||||||
storagePersisted.value = true;
|
_storagePersisted.value = true;
|
||||||
} else {
|
} else {
|
||||||
os.alert({
|
os.alert({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
|
|||||||
Reference in New Issue
Block a user