From fbbc72feabefd9bbbbdbd61a6305194a666e2c63 Mon Sep 17 00:00:00 2001 From: jedi Date: Wed, 31 Jan 2024 22:51:01 +0100 Subject: [PATCH] stash --- web/src/shared-state-plugin/index.js | 58 ++++++++++++++++++++++++++++ web/src/store.js | 6 ++- web/src/utils.js | 2 +- web/src/views/Items.vue | 6 ++- 4 files changed, 67 insertions(+), 5 deletions(-) diff --git a/web/src/shared-state-plugin/index.js b/web/src/shared-state-plugin/index.js index 67397d0..57ae3b8 100644 --- a/web/src/shared-state-plugin/index.js +++ b/web/src/shared-state-plugin/index.js @@ -88,6 +88,64 @@ export default (config) => { } /** 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) { /* globals WebSocket, SharedWorker, onconnect, onmessage, postMessage, close, location */ diff --git a/web/src/store.js b/web/src/store.js index f6c4101..6449abe 100644 --- a/web/src/store.js +++ b/web/src/store.js @@ -140,7 +140,6 @@ const store = createStore({ updateTicket(state, updatedTicket) { const ticket = state.tickets.filter(({id}) => id === updatedTicket.id)[0]; Object.assign(ticket, updatedTicket); - //triggerRef(state.tickets); state.tickets = [...state.tickets]; }, replaceUsers(state, users) { @@ -199,6 +198,9 @@ const store = createStore({ setThumbnail(state, {url, data}) { state.thumbnailCache[url] = data; }, + setThumbnail(state, {url, data}) { + state.thumbnailCache[url] = data; + }, }, actions: { async login({commit}, {username, password, remember}) { @@ -428,7 +430,7 @@ const store = createStore({ ] }), sharedStatePlugin({ - debug: true, + debug: false, isLoadedKey: "shared_loaded", clearingMutation: "logout", afterInit: "afterSharedInit", diff --git a/web/src/utils.js b/web/src/utils.js index 6e9d8e4..21b2e97 100644 --- a/web/src/utils.js +++ b/web/src/utils.js @@ -47,7 +47,7 @@ const http = { method: 'POST', headers: { "Content-Type": "application/json", - "Authorization": `Token ${token}`, + "Authorization": `Token ${data.token}`, }, body: JSON.stringify(data), }); diff --git a/web/src/views/Items.vue b/web/src/views/Items.vue index 5824999..9d127f0 100644 --- a/web/src/views/Items.vue +++ b/web/src/views/Items.vue @@ -23,13 +23,15 @@ >