mirror of https://github.com/Chocobozzz/PeerTube
Merge branch 'release/2.2.0' into develop
commit
a84e6eb11c
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue