@yogiswara/honcho-editor-ui 1.0.14 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -287,17 +287,27 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
|
|
|
287
287
|
}
|
|
288
288
|
}, [controller, loadImageFromUrl]);
|
|
289
289
|
const handlePrev = useCallback(async (firebaseUid) => {
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
290
|
+
// Find the current image index
|
|
291
|
+
const currentIndex = imageList.findIndex(img => img.id === currentImageId);
|
|
292
|
+
// If not the first image, go to previous
|
|
293
|
+
if (currentIndex > 0) {
|
|
294
|
+
const prevImageId = imageList[currentIndex - 1]?.id;
|
|
295
|
+
if (prevImageId) {
|
|
296
|
+
setCurrentImageId(prevImageId);
|
|
297
|
+
}
|
|
293
298
|
}
|
|
294
|
-
}, [imageList]);
|
|
299
|
+
}, [imageList, currentImageId]);
|
|
295
300
|
const handleNext = useCallback(async (firebaseUid) => {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
301
|
+
// Find the current image index
|
|
302
|
+
const currentIndex = imageList.findIndex(img => img.id === currentImageId);
|
|
303
|
+
// If not the last image, go to next
|
|
304
|
+
if (currentIndex < imageList.length - 1 && currentIndex !== -1) {
|
|
305
|
+
const nextImageId = imageList[currentIndex + 1]?.id;
|
|
306
|
+
if (nextImageId) {
|
|
307
|
+
setCurrentImageId(nextImageId);
|
|
308
|
+
}
|
|
299
309
|
}
|
|
300
|
-
}, [imageList]);
|
|
310
|
+
}, [imageList, currentImageId]);
|
|
301
311
|
useEffect(() => {
|
|
302
312
|
if (currentImageId && firebaseUid) {
|
|
303
313
|
loadImageFromId(firebaseUid, currentImageId);
|