diff options
Diffstat (limited to 'client/src/root-helpers/peertube-web-storage.ts')
-rw-r--r-- | client/src/root-helpers/peertube-web-storage.ts | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/client/src/root-helpers/peertube-web-storage.ts b/client/src/root-helpers/peertube-web-storage.ts index 68a2462de..3622cdc44 100644 --- a/client/src/root-helpers/peertube-web-storage.ts +++ b/client/src/root-helpers/peertube-web-storage.ts | |||
@@ -6,19 +6,20 @@ function proxify (instance: MemoryStorage) { | |||
6 | return new Proxy(instance, { | 6 | return new Proxy(instance, { |
7 | set: function (obj, prop: string | symbol, value) { | 7 | set: function (obj, prop: string | symbol, value) { |
8 | if (Object.prototype.hasOwnProperty.call(MemoryStorage, prop)) { | 8 | if (Object.prototype.hasOwnProperty.call(MemoryStorage, prop)) { |
9 | // FIXME: symbol typing issue https://github.com/microsoft/TypeScript/issues/1863 | 9 | // FIXME: remove cast on typescript upgrade |
10 | instance[prop as any] = value | 10 | instance[prop as any] = value |
11 | } else { | 11 | } else { |
12 | instance.setItem(prop, value) | 12 | instance.setItem(prop, value) |
13 | } | 13 | } |
14 | |||
14 | return true | 15 | return true |
15 | }, | 16 | }, |
16 | get: function (target, name: string | symbol | number) { | 17 | get: function (target, name: string | symbol | number) { |
17 | if (Object.prototype.hasOwnProperty.call(MemoryStorage, name)) { | 18 | // FIXME: remove cast on typescript upgrade |
18 | // FIXME: symbol typing issue https://github.com/microsoft/TypeScript/issues/1863 | 19 | if (typeof instance[name as any] === 'function') { |
20 | // FIXME: remove cast on typescript upgrade | ||
19 | return instance[name as any] | 21 | return instance[name as any] |
20 | } | 22 | } else if (valuesMap.has(name)) { |
21 | if (valuesMap.has(name)) { | ||
22 | return instance.getItem(name) | 23 | return instance.getItem(name) |
23 | } | 24 | } |
24 | } | 25 | } |
@@ -83,7 +84,7 @@ try { | |||
83 | } | 84 | } |
84 | 85 | ||
85 | // support Brave and other browsers using null rather than an exception | 86 | // support Brave and other browsers using null rather than an exception |
86 | if (peertubeLocalStorage === null || peertubeSessionStorage === null) { | 87 | if (!peertubeLocalStorage || !peertubeSessionStorage) { |
87 | reinitStorage() | 88 | reinitStorage() |
88 | } | 89 | } |
89 | 90 | ||