mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-14 11:05:47 +02:00
* fix: OAuthのContent-Typeを正しく判定するように * fix(frontend): fix outdated comments * fix: storagePersistenceのtop-level awaitを解消 * fix * fix(frontend): add comment Co-Authored-By: anatawa12 <anatawa12@icloud.com> * fix * fix: rename `users/get-following-users-by-birthday` * fix: fix types * Update MkForm.vue * refactor utility/storage.ts --------- Co-authored-by: anatawa12 <anatawa12@icloud.com> Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
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;
|
|
const storagePersisted = ref(false);
|
|
|
|
export async function getStoragePersistenceStatusRef() {
|
|
if (storagePersistenceSupported) {
|
|
storagePersisted.value = await navigator.storage.persisted().catch(() => false);
|
|
}
|
|
|
|
return readonly(storagePersisted);
|
|
}
|
|
|
|
export async function enableStoragePersistence() {
|
|
if (!storagePersistenceSupported) return;
|
|
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);
|
|
}
|