From 536ac400bc10e61519bc22aba67c5bc05592e009 Mon Sep 17 00:00:00 2001
From: Remi  PLANEL <rplanel@pasteur.fr>
Date: Thu, 4 Apr 2024 20:07:51 +0200
Subject: [PATCH] Fix bug several molstar plugin

---
 components/content/PdbeMolstarPlugin.vue | 11 +++++------
 components/content/pdockqMatrix.vue      | 10 +++++-----
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/components/content/PdbeMolstarPlugin.vue b/components/content/PdbeMolstarPlugin.vue
index 6a082cdd..20424279 100644
--- a/components/content/PdbeMolstarPlugin.vue
+++ b/components/content/PdbeMolstarPlugin.vue
@@ -1,10 +1,7 @@
 <script setup lang="ts">
-import { withTrailingSlash, withLeadingSlash, joinURL } from 'ufo'
-import { useRuntimeConfig, computed, toValue } from '#imports'
+import { computed, toValue } from '#imports'
 import { useDisplay } from "vuetify";
 
-import type { MaybeRef } from "vue"
-import FoldseekDialog from '../FoldseekDialog.vue'
 
 const { mobile, width, height } = useDisplay()
 
@@ -85,8 +82,10 @@ function closeStructure() {
     dialog.value = false
 }
 watch(selectedPdb, (newSelectedPdb, prevSelectPdb) => {
-    viewPdb(newSelectedPdb)
-    structureToDownload.value = newSelectedPdb
+    if (newSelectedPdb !== prevSelectPdb) {
+        viewPdb(newSelectedPdb)
+        structureToDownload.value = newSelectedPdb
+    }
 })
 
 watchEffect(() => {
diff --git a/components/content/pdockqMatrix.vue b/components/content/pdockqMatrix.vue
index cd20fc9e..a76433c7 100644
--- a/components/content/pdockqMatrix.vue
+++ b/components/content/pdockqMatrix.vue
@@ -18,7 +18,7 @@ const filterBase = ref<string[]>([
     "completed='true'"
 ])
 const structureTitle = ref("Structure")
-const stuctureUrls = ref<string[] | undefined>(undefined)
+const structureUrls = ref<string[] | undefined>(undefined)
 
 export interface PlotMargin {
     marginTop: number,
@@ -151,7 +151,7 @@ function on(mark) {
         // 🌶 since a point or band scale doesn't have an inverse, create one from its domain and range
         const g = render.apply(this, arguments);
         const r = d3.select(g).selectChildren();
-        r.on("click", function (event, i) {
+        r.on("click", function (event) {
             const index = d3.select(event.srcElement).data()[0]
             displayStructure(data[index])
         })
@@ -179,7 +179,7 @@ function buildStructureUrl(item) {
 }
 
 function displayStructure(item) {
-    stuctureUrls.value = buildStructureUrl(item).map(url => {
+    structureUrls.value = buildStructureUrl(item).map(url => {
         return toValue(useRefinedUrl(url).refinedUrl)
     })
     structureTitle.value = item.proteins_in_the_prediction.join(" / ")
@@ -194,9 +194,9 @@ function displayStructure(item) {
                 <PlotFigure ref="matrixPlot" :options="unref(option)" defer class="pdockq-plot"
                     :data-label="option.legend.label"></PlotFigure>
             </v-card-text>
-            <PdbeMolstarPlugin v-model="stuctureUrls" v-model:title="structureTitle" />
-        </v-card>
 
+        </v-card>
+        <PdbeMolstarPlugin v-model="structureUrls" v-model:title="structureTitle" />
     </v-row>
     <v-card v-else flat color="transparent">
         <v-card-text>
-- 
GitLab