Merge branch 'release/2.2.0' into develop
This commit is contained in:
commit
a84e6eb11c
|
@ -2,6 +2,27 @@
|
|||
|
||||
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 {
|
||||
[key: string]: any
|
||||
[index: number]: string
|
||||
|
@ -50,27 +71,6 @@ try {
|
|||
const instanceLocalStorage = 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)
|
||||
peertubeSessionStorage = proxify(instanceSessionStorage)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue