aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-05-22 08:50:31 +0200
committerChocobozzz <me@florianbigard.com>2020-05-22 08:50:31 +0200
commitfd8f73cf6d2fa0073de0a7b50d1d9f4598fef9cf (patch)
tree00257635fd2b32ca7e83d4bec925260fac1775aa /client
parentf33dc6ab2db1c733f09dcb039b8bf46c69854753 (diff)
downloadPeerTube-fd8f73cf6d2fa0073de0a7b50d1d9f4598fef9cf.tar.gz
PeerTube-fd8f73cf6d2fa0073de0a7b50d1d9f4598fef9cf.tar.zst
PeerTube-fd8f73cf6d2fa0073de0a7b50d1d9f4598fef9cf.zip
Fix lint
Diffstat (limited to 'client')
-rw-r--r--client/src/app/shared/misc/peertube-web-storage.ts42
1 files changed, 21 insertions, 21 deletions
diff --git a/client/src/app/shared/misc/peertube-web-storage.ts b/client/src/app/shared/misc/peertube-web-storage.ts
index 6a152dd98..0db1301bd 100644
--- a/client/src/app/shared/misc/peertube-web-storage.ts
+++ b/client/src/app/shared/misc/peertube-web-storage.ts
@@ -2,6 +2,27 @@
2 2
3const valuesMap = new Map() 3const valuesMap = new Map()
4 4
5function proxify (instance: MemoryStorage) {
6 return new Proxy(instance, {
7 set: function (obj, prop: string | number, value) {
8 if (MemoryStorage.prototype.hasOwnProperty(prop)) {
9 instance[prop] = value
10 } else {
11 instance.setItem(prop, value)
12 }
13 return true
14 },
15 get: function (target, name: string | number) {
16 if (MemoryStorage.prototype.hasOwnProperty(name)) {
17 return instance[name]
18 }
19 if (valuesMap.has(name)) {
20 return instance.getItem(name)
21 }
22 }
23 })
24}
25
5class MemoryStorage { 26class MemoryStorage {
6 [key: string]: any 27 [key: string]: any
7 [index: number]: string 28 [index: number]: string
@@ -50,27 +71,6 @@ try {
50 const instanceLocalStorage = new MemoryStorage() 71 const instanceLocalStorage = new MemoryStorage()
51 const instanceSessionStorage = new MemoryStorage() 72 const instanceSessionStorage = new MemoryStorage()
52 73
53 function proxify (instance: MemoryStorage) {
54 return new Proxy(instance, {
55 set: function (obj, prop: string | number, value) {
56 if (MemoryStorage.prototype.hasOwnProperty(prop)) {
57 instance[prop] = value
58 } else {
59 instance.setItem(prop, value)
60 }
61 return true
62 },
63 get: function (target, name: string | number) {
64 if (MemoryStorage.prototype.hasOwnProperty(name)) {
65 return instance[name]
66 }
67 if (valuesMap.has(name)) {
68 return instance.getItem(name)
69 }
70 }
71 })
72 }
73
74 peertubeLocalStorage = proxify(instanceLocalStorage) 74 peertubeLocalStorage = proxify(instanceLocalStorage)
75 peertubeSessionStorage = proxify(instanceSessionStorage) 75 peertubeSessionStorage = proxify(instanceSessionStorage)
76} 76}