From ad6f7736c09673637630b680f9a15b8f735f1825 Mon Sep 17 00:00:00 2001 From: isUnknown Date: Thu, 19 Dec 2024 15:02:18 +0100 Subject: [PATCH] Pdf viewer : reload only on file change --- src/components/project/PdfViewer.vue | 8 +++++--- .../project/virtual-sample/Interactive360.vue | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/components/project/PdfViewer.vue b/src/components/project/PdfViewer.vue index 6b8a447..ee8bcc4 100644 --- a/src/components/project/PdfViewer.vue +++ b/src/components/project/PdfViewer.vue @@ -14,7 +14,9 @@ data-icon="comment" @click="isCommentsOpen = !isCommentsOpen" > - {{ isCommentsOpen ? 'Masquer' : 'Afficher' }} les commentaires + {{ isCommentsOpen ? "Masquer" : "Afficher" }} les commentaires @@ -49,8 +51,8 @@ watch(isCommentsOpen, (newVal) => { } }); -watch(openedFile, (newVal) => { - if (!location.href.includes("virtual-sample")) return; +watch(openedFile, (newVal, oldVal) => { + if (newVal.url === oldVal.url) return; isViewerDisabled.value = true; diff --git a/src/components/project/virtual-sample/Interactive360.vue b/src/components/project/virtual-sample/Interactive360.vue index ea7dcad..63014e9 100644 --- a/src/components/project/virtual-sample/Interactive360.vue +++ b/src/components/project/virtual-sample/Interactive360.vue @@ -25,12 +25,14 @@ import throttle from "lodash/throttle"; import { ref, computed, watch } from "vue"; import { useVirtualSampleStore } from "../../../stores/virtualSample"; import { storeToRefs } from "pinia"; +import { useDialogStore } from "../../../stores/dialog"; const { activeTrack } = defineProps({ activeTrack: Object, }); // Helper +const { openedFile } = storeToRefs(useDialogStore()); const virtualSampleStore = useVirtualSampleStore(); const isHelperHidden = ref(localStorage.getItem("isHelperHidden")); localStorage.setItem("isHelperHidden", true); @@ -56,9 +58,16 @@ const currentFileIndex = computed(() => currentY.value + "_" + currentX.value); const currentFile = computed(() => activeTrack.files.find((file) => file.name.includes(currentFileIndex.value)) ); -watch(currentFile, () => (virtualSampleStore.currentFile = currentFile.value), { - immediate: true, -}); +watch( + currentFile, + () => { + virtualSampleStore.currentFile = currentFile.value; + openedFile.value = currentFile.value; + }, + { + immediate: true, + } +); function rotateX(direction) { if (direction == "left") {