diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-11-06 17:42:08 +0100 |
---|---|---|
committer | Rigel Kent <sendmemail@rigelk.eu> | 2020-11-06 17:42:25 +0100 |
commit | 61379e431115ab9d7c200852afcccf6ab94064d5 (patch) | |
tree | 069605f9d5ace01aff6d1527dabcaa15039ff474 /client/src | |
parent | a5c9fa1051c9b658ddc0bf6bd9e7979364316c91 (diff) | |
download | PeerTube-61379e431115ab9d7c200852afcccf6ab94064d5.tar.gz PeerTube-61379e431115ab9d7c200852afcccf6ab94064d5.tar.zst PeerTube-61379e431115ab9d7c200852afcccf6ab94064d5.zip |
check for null local/session storage
fixes #3156
Diffstat (limited to 'client/src')
-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 |