Fix broken client when cookies are disabled
This commit is contained in:
parent
572bf73be6
commit
6189b699fb
|
@ -47,26 +47,32 @@ try {
|
||||||
peertubeLocalStorage = localStorage
|
peertubeLocalStorage = localStorage
|
||||||
peertubeSessionStorage = sessionStorage
|
peertubeSessionStorage = sessionStorage
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const instance = new MemoryStorage()
|
const instanceLocalStorage = new MemoryStorage()
|
||||||
|
const instanceSessionStorage = new MemoryStorage()
|
||||||
|
|
||||||
peertubeLocalStorage = sessionStorage = new Proxy(instance, {
|
function proxify (instance: MemoryStorage) {
|
||||||
set: function (obj, prop: string | number, value) {
|
return new Proxy(instance, {
|
||||||
if (MemoryStorage.prototype.hasOwnProperty(prop)) {
|
set: function (obj, prop: string | number, value) {
|
||||||
instance[prop] = value
|
if (MemoryStorage.prototype.hasOwnProperty(prop)) {
|
||||||
} else {
|
instance[prop] = value
|
||||||
instance.setItem(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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true
|
})
|
||||||
},
|
}
|
||||||
get: function (target, name: string | number) {
|
|
||||||
if (MemoryStorage.prototype.hasOwnProperty(name)) {
|
peertubeLocalStorage = proxify(instanceLocalStorage)
|
||||||
return instance[name]
|
peertubeSessionStorage = proxify(instanceSessionStorage)
|
||||||
}
|
|
||||||
if (valuesMap.has(name)) {
|
|
||||||
return instance.getItem(name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
|
Loading…
Reference in New Issue