From 71291c1ce9de694e350f6bde2aabe7e5cc3e90a7 Mon Sep 17 00:00:00 2001 From: Alicia Sykes Date: Fri, 9 Dec 2022 20:55:49 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Adds=20update=20support=20to=20imag?= =?UTF-8?q?e=20widget=20(#992)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Widgets/ImageWidget.vue | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/Widgets/ImageWidget.vue b/src/components/Widgets/ImageWidget.vue index a556810f..2634b1d2 100644 --- a/src/components/Widgets/ImageWidget.vue +++ b/src/components/Widgets/ImageWidget.vue @@ -9,10 +9,24 @@ import WidgetMixin from '@/mixins/WidgetMixin'; export default { mixins: [WidgetMixin], + data: () => ({ + updateCount: 0, + }), computed: { + /* The path to image to render */ imagePath() { if (!this.options.imagePath) this.error('You must specify an imagePath'); - return this.options.imagePath; + return `${this.options.imagePath}${this.updatePathParam}`; + }, + /* Generate a URL param, to be updated in order to re-fetch image */ + updatePathParam() { + return this.updateCount ? `#dashy-update-${this.updateCount}` : ''; + }, + }, + methods: { + /* In order to re-fetch the image, we much update the URL with an arbitrary hash */ + update() { + this.updateCount += 1; }, }, };