X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Froot-helpers%2Fpeertube-web-storage.ts;h=3622cdc44e74f275408ac4afcebe9c07e8952bbd;hb=3db9f8bf0e653113f0f0f739ad3a32a238062cdb;hp=68a2462de04837d5fa14ec080daa8397d4e5b87f;hpb=9df52d660feb722404be00a50f3c8a612bec1c15;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/root-helpers/peertube-web-storage.ts b/client/src/root-helpers/peertube-web-storage.ts index 68a2462de..3622cdc44 100644 --- a/client/src/root-helpers/peertube-web-storage.ts +++ b/client/src/root-helpers/peertube-web-storage.ts @@ -6,19 +6,20 @@ function proxify (instance: MemoryStorage) { return new Proxy(instance, { set: function (obj, prop: string | symbol, value) { if (Object.prototype.hasOwnProperty.call(MemoryStorage, prop)) { - // FIXME: symbol typing issue https://github.com/microsoft/TypeScript/issues/1863 + // FIXME: remove cast on typescript upgrade instance[prop as any] = value } else { instance.setItem(prop, value) } + return true }, get: function (target, name: string | symbol | number) { - if (Object.prototype.hasOwnProperty.call(MemoryStorage, name)) { - // FIXME: symbol typing issue https://github.com/microsoft/TypeScript/issues/1863 + // FIXME: remove cast on typescript upgrade + if (typeof instance[name as any] === 'function') { + // FIXME: remove cast on typescript upgrade return instance[name as any] - } - if (valuesMap.has(name)) { + } else if (valuesMap.has(name)) { return instance.getItem(name) } } @@ -83,7 +84,7 @@ try { } // support Brave and other browsers using null rather than an exception -if (peertubeLocalStorage === null || peertubeSessionStorage === null) { +if (!peertubeLocalStorage || !peertubeSessionStorage) { reinitStorage() }