From b0f9563936b29f2c958a715cc15789dd6617d33b Mon Sep 17 00:00:00 2001
From: Anthony Geourjon <anthony.geourjon@tetras-libre.fr>
Date: Tue, 6 Feb 2024 13:52:44 +0100
Subject: [PATCH] App not crashing when opening image viewer

---
 src/AnnotationCreation.js                  | 23 ++++++++++++++++++----
 src/annotationForm/AnnotationFormFooter.js |  2 ++
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/AnnotationCreation.js b/src/AnnotationCreation.js
index 5dee864..dd37869 100644
--- a/src/AnnotationCreation.js
+++ b/src/AnnotationCreation.js
@@ -288,7 +288,7 @@ function AnnotationCreation({
     imageEvent,
   } = toolState;
 
-  const mediaIsVideo = mediaVideo !== 'undefined';
+  const mediaIsVideo = mediaVideo !== undefined;
   if (mediaIsVideo && valueTime) {
     valueTime[0] = tstart;
     valueTime[1] = tend;
@@ -302,9 +302,23 @@ function AnnotationCreation({
   let overlay = null;
   if (videoref) {
     overlay = videoref.canvasOverlay;
-  }
-  if (osdref) {
-    console.debug('osdref', osdref);
+  } else {
+    if (osdref) {
+      console.debug('osdref', osdref);
+      overlay = {
+        canvasHeight: osdref.current.canvas.clientHeight,
+        canvasWidth: osdref.current.canvas.clientWidth,
+        containerHeight: osdref.current.canvas.clientHeight,
+        containerWidth: osdref.current.canvas.clientWidth,
+      };
+    } else {
+      overlay = {
+        canvasHeight: 500,
+        canvasWidth: 1000,
+        containerHeight: 500,
+        containerWidth: 1000,
+      };
+    }
   }
 
   /** Change scale from container / canva */
@@ -430,6 +444,7 @@ function AnnotationCreation({
           resetStateAfterSave={resetStateAfterSave}
           state={state}
           windowId={windowId}
+          mediaIsVideo={mediaIsVideo}
         />
       </StyledForm>
     </CompanionWindow>
diff --git a/src/annotationForm/AnnotationFormFooter.js b/src/annotationForm/AnnotationFormFooter.js
index b7dbb88..656786e 100644
--- a/src/annotationForm/AnnotationFormFooter.js
+++ b/src/annotationForm/AnnotationFormFooter.js
@@ -23,10 +23,12 @@ function AnnotationFormFooter({
   closeFormCompanionWindow,
   config,
   drawingState,
+  mediaIsVideo,
   receiveAnnotation,
   resetStateAfterSave,
   state,
   windowId,
+
 }) {
   /**
    * Validate form and save annotation
-- 
GitLab