From 4b11264dfea1f459d556d9ed1d02f2f36de392c6 Mon Sep 17 00:00:00 2001 From: jedi Date: Wed, 13 Dec 2023 02:00:59 +0100 Subject: [PATCH] stash --- web/src/components/AuthenticatedImage.vue | 24 +++++++++++++---------- web/src/store/index.js | 5 +++-- web/src/views/Items.vue | 2 +- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/web/src/components/AuthenticatedImage.vue b/web/src/components/AuthenticatedImage.vue index 67a64c6..921b562 100644 --- a/web/src/components/AuthenticatedImage.vue +++ b/web/src/components/AuthenticatedImage.vue @@ -23,17 +23,21 @@ export default { servers: [] } }, - methods: mapActions(['fetchImage']), - async mounted() { - try { - const response = await this.fetchImage(this.src); - const mime_type = response.headers.get("content-type"); - const base64 = btoa(new Uint8Array(await response.arrayBuffer()) - .reduce((data, byte) => data + String.fromCharCode(byte), "")); - this.image_data = "data:" + mime_type + ";base64," + base64; - } catch (e) { - console.log(e); + methods: { + ...mapActions(['fetchImage']), + loadImage() { + this.fetchImage(this.src).then((response) => { + const mime_type = response.headers.get("content-type"); + response.arrayBuffer().then((buf) => { + const base64 = btoa(new Uint8Array(buf) + .reduce((data, byte) => data + String.fromCharCode(byte), "")); + this.image_data = "data:" + mime_type + ";base64," + base64; + }); + }) } + }, + mounted() { + this.loadImage(); } } \ No newline at end of file diff --git a/web/src/store/index.js b/web/src/store/index.js index 12ae214..1f57aa1 100644 --- a/web/src/store/index.js +++ b/web/src/store/index.js @@ -208,14 +208,15 @@ const store = new Vuex.Store({ await dispatch('loadTickets'); }, async fetchImage({state}, url) { - return await fetch(url, {headers: {'Authorization': `Token ${state.token}`}}).then(r => r.blob()); + return await fetch(url, {headers: {'Authorization': `Token ${state.token}`}}); }, async loadEvents({commit}) { const {data} = await axios.get('/2/events/'); commit('replaceEvents', data); }, - changeEvent({dispatch, getters}, eventName) { + changeEvent({dispatch, getters, commit}, eventName) { router.push({path: `/${eventName.slug}/${getters.getActiveView}/`}); + commit('replaceLoadedItems', []); dispatch('loadEventItems'); }, changeView({getters}, link) { diff --git a/web/src/views/Items.vue b/web/src/views/Items.vue index 32fa477..9ed1474 100644 --- a/web/src/views/Items.vue +++ b/web/src/views/Items.vue @@ -44,7 +44,7 @@ v-slot="{ item }" @itemActivated="openLightboxModalWith($event)" > -