From 1c1cf584090e02b79454aa4d443782111e8c9baa Mon Sep 17 00:00:00 2001 From: caranicas Date: Sun, 25 Sep 2022 11:00:53 -0400 Subject: [PATCH] fix shift --- .../src/components/organisms/displayPanel/index.tsx | 5 ++--- ui/frontend/build_src/src/stores/imageDisplayStore.ts | 5 +---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/ui/frontend/build_src/src/components/organisms/displayPanel/index.tsx b/ui/frontend/build_src/src/components/organisms/displayPanel/index.tsx index e25ce5d3..786b9442 100644 --- a/ui/frontend/build_src/src/components/organisms/displayPanel/index.tsx +++ b/ui/frontend/build_src/src/components/organisms/displayPanel/index.tsx @@ -228,12 +228,11 @@ export default function DisplayPanel() { null ); - const len = useImageDisplay((state) => state.len); const getCurrentImage = useImageDisplay((state) => state.getCurrentImage); const images = useImageDisplay((state) => state.images); useEffect(() => { - if (len > 0) { + if (images.length > 0) { debugger; const cur = getCurrentImage(); console.log("cur", cur); @@ -241,7 +240,7 @@ export default function DisplayPanel() { } else { setCurrentImage(null); } - }, [len, getCurrentImage]); + }, [images, getCurrentImage]); // useEffect(() => { // console.log("images CHANGED"); diff --git a/ui/frontend/build_src/src/stores/imageDisplayStore.ts b/ui/frontend/build_src/src/stores/imageDisplayStore.ts index 79956b25..4d8e807d 100644 --- a/ui/frontend/build_src/src/stores/imageDisplayStore.ts +++ b/ui/frontend/build_src/src/stores/imageDisplayStore.ts @@ -15,7 +15,6 @@ interface ImageDisplayState { export const useImageDisplay = create((set, get) => ({ // imageOptions: new Map(), images: [], - len: 0, // currentImage: null, // use produce to make sure we don't mutate state // imageOptions: any @@ -25,9 +24,7 @@ export const useImageDisplay = create((set, get) => ({ // options: imageOptions // state.currentImage = { display: ImageData, imageOptions }; // imageOptions - state.images.push({ data: ImageData, info: imageOptions }); - state.len += 1; - debugger + state.images.unshift({ data: ImageData, info: imageOptions }); }) ); },