diff options
Diffstat (limited to 'packages/frontend/src/utility/storage.ts')
| -rw-r--r-- | packages/frontend/src/utility/storage.ts | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/packages/frontend/src/utility/storage.ts b/packages/frontend/src/utility/storage.ts index 9df3a251e6..42743f78ea 100644 --- a/packages/frontend/src/utility/storage.ts +++ b/packages/frontend/src/utility/storage.ts @@ -3,14 +3,24 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { computed, ref, shallowRef, watch, defineAsyncComponent } 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 storagePersisted = ref(await navigator.storage.persisted()); +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) { |