this doesn't work in strict mode which the SDK is exported as

See https://github.com/vector-im/hydrogen-web/pull/373/files#r927145321
This commit is contained in:
Eric Eastwood 2022-07-21 17:23:49 -05:00
parent 871cf1ad80
commit c824012968

View file

@ -34,12 +34,11 @@ interface ServiceWorkerHandler {
async function requestPersistedStorage(): Promise<boolean> {
// don't assume browser so we can run in node with fake-idb
const glob = this;
if (glob?.navigator?.storage?.persist) {
return await glob.navigator.storage.persist();
} else if (glob?.document.requestStorageAccess) {
if (window?.navigator?.storage?.persist) {
return await window.navigator.storage.persist();
} else if (window?.document.requestStorageAccess) {
try {
await glob.document.requestStorageAccess();
await window.document.requestStorageAccess();
return true;
} catch (err) {
return false;