aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/root-helpers/peertube-web-storage.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/root-helpers/peertube-web-storage.ts')
-rw-r--r--client/src/root-helpers/peertube-web-storage.ts19
1 files changed, 15 insertions, 4 deletions
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 {
64 64
65let peertubeLocalStorage: Storage 65let peertubeLocalStorage: Storage
66let peertubeSessionStorage: Storage 66let peertubeSessionStorage: Storage
67try { 67
68 peertubeLocalStorage = localStorage 68function reinitStorage () {
69 peertubeSessionStorage = sessionStorage
70} catch (err) {
71 const instanceLocalStorage = new MemoryStorage() 69 const instanceLocalStorage = new MemoryStorage()
72 const instanceSessionStorage = new MemoryStorage() 70 const instanceSessionStorage = new MemoryStorage()
73 71
@@ -75,6 +73,19 @@ try {
75 peertubeSessionStorage = proxify(instanceSessionStorage) 73 peertubeSessionStorage = proxify(instanceSessionStorage)
76} 74}
77 75
76try {
77 peertubeLocalStorage = localStorage
78 peertubeSessionStorage = sessionStorage
79} catch (err) {
80 // support Firefox and other browsers using an exception rather than null
81 reinitStorage()
82}
83
84// support Brave and other browsers using null rather than an exception
85if (peertubeLocalStorage === null || peertubeSessionStorage === null) {
86 reinitStorage()
87}
88
78export { 89export {
79 peertubeLocalStorage, 90 peertubeLocalStorage,
80 peertubeSessionStorage 91 peertubeSessionStorage