Merge branch 'release/2.2.0' into develop

pull/2780/head
Chocobozzz 2020-05-22 09:14:08 +02:00
commit a84e6eb11c
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 21 additions and 21 deletions

View File

@ -2,6 +2,27 @@
const valuesMap = new Map() const valuesMap = new Map()
function proxify (instance: MemoryStorage) {
return new Proxy(instance, {
set: function (obj, prop: string | number, value) {
if (MemoryStorage.prototype.hasOwnProperty(prop)) {
instance[prop] = value
} else {
instance.setItem(prop, value)
}
return true
},
get: function (target, name: string | number) {
if (MemoryStorage.prototype.hasOwnProperty(name)) {
return instance[name]
}
if (valuesMap.has(name)) {
return instance.getItem(name)
}
}
})
}
class MemoryStorage { class MemoryStorage {
[key: string]: any [key: string]: any
[index: number]: string [index: number]: string
@ -50,27 +71,6 @@ try {
const instanceLocalStorage = new MemoryStorage() const instanceLocalStorage = new MemoryStorage()
const instanceSessionStorage = new MemoryStorage() const instanceSessionStorage = new MemoryStorage()
function proxify (instance: MemoryStorage) {
return new Proxy(instance, {
set: function (obj, prop: string | number, value) {
if (MemoryStorage.prototype.hasOwnProperty(prop)) {
instance[prop] = value
} else {
instance.setItem(prop, value)
}
return true
},
get: function (target, name: string | number) {
if (MemoryStorage.prototype.hasOwnProperty(name)) {
return instance[name]
}
if (valuesMap.has(name)) {
return instance.getItem(name)
}
}
})
}
peertubeLocalStorage = proxify(instanceLocalStorage) peertubeLocalStorage = proxify(instanceLocalStorage)
peertubeSessionStorage = proxify(instanceSessionStorage) peertubeSessionStorage = proxify(instanceSessionStorage)
} }