This commit is contained in:
j3d1 2024-01-31 22:51:01 +01:00
parent 50d3dec166
commit 89f5b77b6e
3 changed files with 62 additions and 1 deletions

View file

@ -88,6 +88,64 @@ export default (config) => {
} }
/** may only be called from worker */ /** may only be called from worker */
const clone = (obj) => {
if (isProxy(obj)) {
obj = toRaw(obj);
}
if (obj === null || typeof obj !== 'object') {
return obj;
}
if (obj.__proto__ === ({}).__proto__) {
return Object.assign({}, obj);
}
if (obj.__proto__ === [].__proto__) {
return obj.slice();
}
return obj;
}
const deepEqual = (a, b) => {
if (a === b) {
return true;
}
if (a === null || b === null) {
return false;
}
if (a.__proto__ === ({}).__proto__ && b.__proto__ === ({}).__proto__) {
if (Object.keys(a).length !== Object.keys(b).length) {
return false;
}
for (let key in b) {
if (!(key in a)) {
return false;
}
}
for (let key in a) {
if (!(key in b)) {
return false;
}
if (!deepEqual(a[key], b[key])) {
return false;
}
}
return true;
}
if (a.__proto__ === [].__proto__ && b.__proto__ === [].__proto__) {
if (a.length !== b.length) {
return false;
}
for (let i = 0; i < a.length; i++) {
if (!deepEqual(a[i], b[i])) {
return false;
}
}
return true;
}
return false;
}
const worker_fun = function (self, ctx) { const worker_fun = function (self, ctx) {
/* globals WebSocket, SharedWorker, onconnect, onmessage, postMessage, close, location */ /* globals WebSocket, SharedWorker, onconnect, onmessage, postMessage, close, location */

View file

@ -215,6 +215,9 @@ const store = createStore({
setThumbnail(state, {url, data}) { setThumbnail(state, {url, data}) {
state.thumbnailCache[url] = data; state.thumbnailCache[url] = data;
}, },
setThumbnail(state, {url, data}) {
state.thumbnailCache[url] = data;
},
setShippingVouchers(state, codes) { setShippingVouchers(state, codes) {
state.shippingVouchers = codes; state.shippingVouchers = codes;
state.fetchedData = {...state.fetchedData, shippingVouchers: Date.now()}; state.fetchedData = {...state.fetchedData, shippingVouchers: Date.now()};

View file

@ -47,7 +47,7 @@ const http = {
method: 'POST', method: 'POST',
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
"Authorization": `Token ${token}`, "Authorization": `Token ${data.token}`,
}, },
body: JSON.stringify(data), body: JSON.stringify(data),
}); });