From e91b64ca97369552d6033345f32fd3cec666e52e Mon Sep 17 00:00:00 2001 From: jedi Date: Sat, 22 Jun 2024 22:11:38 +0200 Subject: [PATCH] software caching thumbnails in javascript --- web/src/components/AuthenticatedImage.vue | 37 +++++++++++++++++------ web/src/components/TimelineMail.vue | 4 +-- web/src/store.js | 12 +++++++- web/src/views/Empty.vue | 17 ++++++++--- web/src/views/Items.vue | 2 +- 5 files changed, 54 insertions(+), 18 deletions(-) diff --git a/web/src/components/AuthenticatedImage.vue b/web/src/components/AuthenticatedImage.vue index 921b562..9e1a963 100644 --- a/web/src/components/AuthenticatedImage.vue +++ b/web/src/components/AuthenticatedImage.vue @@ -7,7 +7,7 @@ \ No newline at end of file diff --git a/web/src/components/TimelineMail.vue b/web/src/components/TimelineMail.vue index 0c0f6f7..065d56a 100644 --- a/web/src/components/TimelineMail.vue +++ b/web/src/components/TimelineMail.vue @@ -25,8 +25,8 @@ diff --git a/web/src/store.js b/web/src/store.js index b15ee65..94bfc70 100644 --- a/web/src/store.js +++ b/web/src/store.js @@ -29,8 +29,9 @@ const store = createStore({ expiry: null, }, - showAddBoxModal: false, + thumbnailCache: {}, persistent_loaded: false, + showAddBoxModal: false, }, getters: { route: state => router.currentRoute.value, @@ -71,6 +72,12 @@ const store = createStore({ isLoggedIn(state) { return state.user && state.user.username !== null && state.user.token !== null; }, + getThumbnail: (state) => (url) => { + if (!url) return null; + if (!(url in state.thumbnailCache)) + return null; + return state.thumbnailCache[url]; + }, }, mutations: { updateLastEvent(state, slug) { @@ -162,6 +169,9 @@ const store = createStore({ user.permissions = null; state.user = user; }, + setThumbnail(state, {url, data}) { + state.thumbnailCache[url] = data; + }, }, actions: { async login({commit}, {username, password, remember}) { diff --git a/web/src/views/Empty.vue b/web/src/views/Empty.vue index 4c7c3eb..ef221da 100644 --- a/web/src/views/Empty.vue +++ b/web/src/views/Empty.vue @@ -4,9 +4,16 @@
-

User: {{user}}

+

User: {{ activeUser }}

-
+
+

Your Account is activated. Got to + Items + or + Tickets +

+
+

Your Account is not yet activated. Please contact an admin.

@@ -16,11 +23,13 @@ diff --git a/web/src/views/Items.vue b/web/src/views/Items.vue index 04d08fb..2eec96f 100644 --- a/web/src/views/Items.vue +++ b/web/src/views/Items.vue @@ -45,7 +45,7 @@ v-slot="{ item }" @itemActivated="openLightboxModalWith($event)" > -