diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/src/root-helpers/peertube-web-storage.ts | 19 |
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 | ||
65 | let peertubeLocalStorage: Storage | 65 | let peertubeLocalStorage: Storage |
66 | let peertubeSessionStorage: Storage | 66 | let peertubeSessionStorage: Storage |
67 | try { | 67 | |
68 | peertubeLocalStorage = localStorage | 68 | function 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 | ||
76 | try { | ||
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 | ||
85 | if (peertubeLocalStorage === null || peertubeSessionStorage === null) { | ||
86 | reinitStorage() | ||
87 | } | ||
88 | |||
78 | export { | 89 | export { |
79 | peertubeLocalStorage, | 90 | peertubeLocalStorage, |
80 | peertubeSessionStorage | 91 | peertubeSessionStorage |