aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-10-08 11:57:39 +0200
committerChocobozzz <me@florianbigard.com>2021-10-08 11:57:39 +0200
commitdd0ad8dfa5a4cdab066602668ed182cb45098e10 (patch)
tree070fd31a91f3ba910a6b7b5c99c46fa783630a28
parent8e7442d0d818ef25240b46dd1115187c7c042a3a (diff)
downloadPeerTube-dd0ad8dfa5a4cdab066602668ed182cb45098e10.tar.gz
PeerTube-dd0ad8dfa5a4cdab066602668ed182cb45098e10.tar.zst
PeerTube-dd0ad8dfa5a4cdab066602668ed182cb45098e10.zip
Fix local/session storage polyfill
-rw-r--r--client/src/root-helpers/peertube-web-storage.ts16
-rw-r--r--client/src/standalone/videos/test-embed.ts2
2 files changed, 9 insertions, 9 deletions
diff --git a/client/src/root-helpers/peertube-web-storage.ts b/client/src/root-helpers/peertube-web-storage.ts
index 68a2462de..0bbe2c9fc 100644
--- a/client/src/root-helpers/peertube-web-storage.ts
+++ b/client/src/root-helpers/peertube-web-storage.ts
@@ -6,19 +6,17 @@ 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 instance[prop] = value
10 instance[prop as any] = value
11 } else { 10 } else {
12 instance.setItem(prop, value) 11 instance.setItem(prop, value)
13 } 12 }
13
14 return true 14 return true
15 }, 15 },
16 get: function (target, name: string | symbol | number) { 16 get: function (target, name: string | symbol | number) {
17 if (Object.prototype.hasOwnProperty.call(MemoryStorage, name)) { 17 if (typeof instance[name] === 'function') {
18 // FIXME: symbol typing issue https://github.com/microsoft/TypeScript/issues/1863 18 return instance[name]
19 return instance[name as any] 19 } else if (valuesMap.has(name)) {
20 }
21 if (valuesMap.has(name)) {
22 return instance.getItem(name) 20 return instance.getItem(name)
23 } 21 }
24 } 22 }
@@ -26,7 +24,7 @@ function proxify (instance: MemoryStorage) {
26} 24}
27 25
28class MemoryStorage implements Storage { 26class MemoryStorage implements Storage {
29 [key: string]: any 27 [key: string | symbol]: any
30 28
31 getItem (key: any) { 29 getItem (key: any) {
32 const stringKey = String(key) 30 const stringKey = String(key)
@@ -83,7 +81,7 @@ try {
83} 81}
84 82
85// support Brave and other browsers using null rather than an exception 83// support Brave and other browsers using null rather than an exception
86if (peertubeLocalStorage === null || peertubeSessionStorage === null) { 84if (!peertubeLocalStorage || !peertubeSessionStorage) {
87 reinitStorage() 85 reinitStorage()
88} 86}
89 87
diff --git a/client/src/standalone/videos/test-embed.ts b/client/src/standalone/videos/test-embed.ts
index 301c95d7b..a28a83cc1 100644
--- a/client/src/standalone/videos/test-embed.ts
+++ b/client/src/standalone/videos/test-embed.ts
@@ -15,6 +15,8 @@ window.addEventListener('load', async () => {
15 ? `/video-playlists/embed/${elementId}?api=1` 15 ? `/video-playlists/embed/${elementId}?api=1`
16 : `/videos/embed/${elementId}?api=1` 16 : `/videos/embed/${elementId}?api=1`
17 17
18 iframe.sandbox.add('allow-same-origin', 'allow-scripts', 'allow-popups')
19
18 const mainElement = document.querySelector('#host') 20 const mainElement = document.querySelector('#host')
19 mainElement.appendChild(iframe) 21 mainElement.appendChild(iframe)
20 22