X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Froot-helpers%2Fpeertube-web-storage.ts;h=f29845443ab8207be9a017f44fb0418284f67c71;hb=210856a7be4631540791bad027fb3ef0f7a51f14;hp=0db1301bd4fa4846b1e6d3096e0417d49849c527;hpb=4504f09f6e85f09b0489debb547a17209d7176ea;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 0db1301bd..f29845443 100644 --- a/client/src/root-helpers/peertube-web-storage.ts +++ b/client/src/root-helpers/peertube-web-storage.ts @@ -64,10 +64,8 @@ class MemoryStorage { let peertubeLocalStorage: Storage let peertubeSessionStorage: Storage -try { - peertubeLocalStorage = localStorage - peertubeSessionStorage = sessionStorage -} catch (err) { + +function reinitStorage () { const instanceLocalStorage = new MemoryStorage() const instanceSessionStorage = new MemoryStorage() @@ -75,6 +73,19 @@ try { peertubeSessionStorage = proxify(instanceSessionStorage) } +try { + peertubeLocalStorage = localStorage + peertubeSessionStorage = sessionStorage +} catch (err) { + // support Firefox and other browsers using an exception rather than null + reinitStorage() +} + +// support Brave and other browsers using null rather than an exception +if (peertubeLocalStorage === null || peertubeSessionStorage === null) { + reinitStorage() +} + export { peertubeLocalStorage, peertubeSessionStorage