From 9f2d847d693b68ff3e49f67a0182498d0befc2b3 Mon Sep 17 00:00:00 2001 From: bonomite Date: Thu, 18 Apr 2024 13:39:37 -0400 Subject: [PATCH] VImage watcher for changes in prop when episode switches to different sources --- v2/src/components/VImage.vue | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/v2/src/components/VImage.vue b/v2/src/components/VImage.vue index 9bcea67..8b05329 100644 --- a/v2/src/components/VImage.vue +++ b/v2/src/components/VImage.vue @@ -3,6 +3,7 @@ import VImageNpr from "./VImageNpr.vue" import VImagePublisher from "./VImagePublisher.vue" import VImageWagtail from "./VImageWagtail.vue" import { cmsSources, getCmsSource } from "./helpers.js" +import { ref, watch } from "vue" const props = defineProps({ src: { @@ -10,8 +11,15 @@ const props = defineProps({ type: String, }, }) +const cmsSource = ref(getCmsSource(props.src)) -const cmsSource = getCmsSource(props.src) +// Watch the 'src' prop for changes and update 'cmsSource' accordingly +watch( + () => props.src, + (newSrc) => { + cmsSource.value = getCmsSource(newSrc) + } +)