fix shift

This commit is contained in:
caranicas 2022-09-25 11:00:53 -04:00
parent 8155e3ef7a
commit 1c1cf58409
2 changed files with 3 additions and 7 deletions

View File

@ -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");

View File

@ -15,7 +15,6 @@ interface ImageDisplayState {
export const useImageDisplay = create<ImageDisplayState>((set, get) => ({
// imageOptions: new Map<string, any>(),
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<ImageDisplayState>((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 });
})
);
},