From 57c85fbbfcb54bd2095c48b9a7847dd948e6b87c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mi=C5=82osz=20Grocholewski?= <m.grocholewski@atcomp.pl>
Date: Thu, 21 Nov 2024 09:05:49 +0100
Subject: [PATCH] refactor(vector-map): rendering modifications after element
 rendering

---
 .../utils/shapes/elements/MapElement.ts       | 24 +++++++++----------
 src/redux/bioEntity/bioEntity.reducers.ts     | 18 +++++++-------
 2 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement.ts b/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement.ts
index 94d5f96f..f485c3fb 100644
--- a/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement.ts
+++ b/src/components/Map/MapViewer/MapViewerVector/utils/shapes/elements/MapElement.ts
@@ -156,18 +156,6 @@ export default class MapElement extends BaseMultiPolygon {
   }
 
   protected createPolygons(): void {
-    this.modifications.forEach(modification => {
-      if (modification.state === null) {
-        return;
-      }
-
-      const shapes = this.bioShapes[modification.sboTerm];
-      if (!shapes) {
-        return;
-      }
-      this.drawModification(modification, shapes);
-    });
-
     if (this.lineType) {
       this.lineDash = this.lineTypes[this.lineType] || [];
     }
@@ -181,6 +169,18 @@ export default class MapElement extends BaseMultiPolygon {
       this.drawElementPolygon(homodimerShift, homodimerOffset);
     }
     this.drawOverlays();
+
+    this.modifications.forEach(modification => {
+      if (modification.state === null) {
+        return;
+      }
+
+      const shapes = this.bioShapes[modification.sboTerm];
+      if (!shapes) {
+        return;
+      }
+      this.drawModification(modification, shapes);
+    });
   }
 
   drawModification(modification: Modification, shapes: Array<Shape>): void {
diff --git a/src/redux/bioEntity/bioEntity.reducers.ts b/src/redux/bioEntity/bioEntity.reducers.ts
index f5f4f94c..57c38c9d 100644
--- a/src/redux/bioEntity/bioEntity.reducers.ts
+++ b/src/redux/bioEntity/bioEntity.reducers.ts
@@ -141,18 +141,18 @@ export const setMultipleBioEntityContentsReducer = (
   state: BioEntityContentsState,
   action: PayloadAction<Array<BioEntity>>,
 ): void => {
-  state.data = [
-    {
-      data: action.payload.map(bioEntity => {
-        return {
+  state.data = action.payload.map(bioEntity => {
+    return {
+      data: [
+        {
           bioEntity,
           perfect: true,
-        };
-      }),
+        },
+      ],
+      searchQueryElement: bioEntity.id.toString(),
       loading: 'succeeded',
       error: DEFAULT_ERROR,
-      searchQueryElement: 'asd',
-    },
-  ];
+    };
+  });
   state.loading = 'succeeded';
 };
-- 
GitLab