aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2020-11-06 17:42:08 +0100
committerRigel Kent <sendmemail@rigelk.eu>2020-11-06 17:42:25 +0100
commit61379e431115ab9d7c200852afcccf6ab94064d5 (patch)
tree069605f9d5ace01aff6d1527dabcaa15039ff474 /client/src
parenta5c9fa1051c9b658ddc0bf6bd9e7979364316c91 (diff)
downloadPeerTube-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.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