From 4243029870555d9b851f0cc3e6cd3456577288fe Mon Sep 17 00:00:00 2001 From: Wilhelm Vold Date: Tue, 15 Oct 2024 14:04:53 +0200 Subject: [PATCH] fix: removed unneccecary code and warnings --- .../ImageView/ModelImageCanvas/ModelImageCanvas.tsx | 5 +++-- .../ModelView/ModelMetadataView/ModelMetadataView.tsx | 11 ++--------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/components/ImageView/ModelImageCanvas/ModelImageCanvas.tsx b/src/components/ImageView/ModelImageCanvas/ModelImageCanvas.tsx index f9028a7..1a46e21 100644 --- a/src/components/ImageView/ModelImageCanvas/ModelImageCanvas.tsx +++ b/src/components/ImageView/ModelImageCanvas/ModelImageCanvas.tsx @@ -45,8 +45,9 @@ export const ModelImageCanvas = ({ img.onload = () => { // Scale image down based on the size of the parent const container = canvas.parentElement; - const containerWidth = container!.clientWidth; - const containerHeight = container!.clientHeight; + if (container === null) return; + const containerWidth = container.clientWidth; + const containerHeight = container.clientHeight; const scaleX = containerWidth / img.width; const scaleY = containerHeight / img.height; const scale = Math.min(scaleX, scaleY); // Use the smaller scale factor diff --git a/src/features/ModelView/ModelMetadataView/ModelMetadataView.tsx b/src/features/ModelView/ModelMetadataView/ModelMetadataView.tsx index 3ef71d6..72dc860 100644 --- a/src/features/ModelView/ModelMetadataView/ModelMetadataView.tsx +++ b/src/features/ModelView/ModelMetadataView/ModelMetadataView.tsx @@ -1,8 +1,8 @@ /* eslint-disable max-lines */ /* eslint-disable max-lines-per-function */ -import { Button, Dialog, Typography } from '@equinor/eds-core-react'; +import { Button, Typography } from '@equinor/eds-core-react'; import { useMutation, useQuery } from '@tanstack/react-query'; -import { useCallback, useEffect, useRef,useState } from 'react'; +import { useCallback, useEffect, useRef, useState } from 'react'; import { useParams } from 'react-router-dom'; import { AddAnalogueModelMetadataCommandForm, @@ -26,7 +26,6 @@ import { EditNameDescription } from '../EditNameDescription/EditNameDescription' import * as Styled from './ModelMetadataView.styled'; import { getAnalogueModelImage } from '../../../api/custom/getAnalogueModelImageById'; - export const ModelMetadataView = ({ modelIdParent, uploadingProgress, @@ -41,14 +40,8 @@ export const ModelMetadataView = ({ const generateImageRequested = useRef(false); - const [stratColumnObject, setStratColumnObject] = useState( - defaultStratColumnData, - ); - const [showStratColDialog, setShowStratColDialog] = useState(false); - const { modelId } = useParams(); - const defaultMetadata: AnalogueModelDetail = { analogueModelId: data?.data.analogueModelId ? data?.data.analogueModelId