@yogiswara/honcho-editor-ui 1.3.6 → 1.3.8
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.
|
@@ -256,6 +256,7 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
|
|
|
256
256
|
const loadImageFromUrl = useCallback(async (url) => {
|
|
257
257
|
try {
|
|
258
258
|
setEditorStatus("Downloading image...");
|
|
259
|
+
console.log(`[DEBUG] Attempting to fetch image from URL: ${url}`);
|
|
259
260
|
const response = await fetch(url);
|
|
260
261
|
if (!response.ok)
|
|
261
262
|
throw new Error(`Failed to fetch image from URL: ${url}`);
|
|
@@ -278,6 +279,7 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
|
|
|
278
279
|
const imagePath = gallery?.raw_edited?.path
|
|
279
280
|
? gallery.raw_edited.path
|
|
280
281
|
: gallery?.download?.path;
|
|
282
|
+
console.log("[DEBUG] Extracted imagePath to load:", imagePath);
|
|
281
283
|
if (imagePath) {
|
|
282
284
|
await loadImageFromUrl(imagePath);
|
|
283
285
|
return gallery; // ✅ RETURN the gallery object on success
|
|
@@ -354,26 +356,6 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
|
|
|
354
356
|
imageList, currentImageId, hasNextPage,
|
|
355
357
|
isFetchingNextPage, currentPage, controller, firebaseUid, eventId
|
|
356
358
|
]);
|
|
357
|
-
useEffect(() => {
|
|
358
|
-
// This is now the single point of control for loading an image based on the initial props.
|
|
359
|
-
// 1. First, check if all conditions are met to even attempt loading.
|
|
360
|
-
// We ensure the editor itself is ready before doing anything.
|
|
361
|
-
const canLoad = initImageId && firebaseUid && controller && isEditorReady;
|
|
362
|
-
if (!canLoad) {
|
|
363
|
-
return;
|
|
364
|
-
}
|
|
365
|
-
// 2. Define the loading sequence as an async function inside the effect.
|
|
366
|
-
const loadInitialImage = async () => {
|
|
367
|
-
console.log(`[EFFECT] Starting to load initial image ID: ${initImageId}`);
|
|
368
|
-
// This directly calls the loading function. We don't need to set
|
|
369
|
-
// an intermediate 'currentImageId' state, which avoids an extra re-render and potential loop.
|
|
370
|
-
await loadImageFromId(firebaseUid, initImageId);
|
|
371
|
-
};
|
|
372
|
-
// 3. Execute the loading sequence.
|
|
373
|
-
loadInitialImage();
|
|
374
|
-
// Dependencies: The external props and readiness flags that trigger this logic.
|
|
375
|
-
// Whenever any of these change, this effect will re-evaluate.
|
|
376
|
-
}, [initImageId, firebaseUid, controller, isEditorReady, loadImageFromId]);
|
|
377
359
|
useEffect(() => {
|
|
378
360
|
const initialize = async () => {
|
|
379
361
|
if (initImageId && firebaseUid && controller && isEditorReady) {
|
|
@@ -413,14 +395,14 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
|
|
|
413
395
|
};
|
|
414
396
|
initialize();
|
|
415
397
|
}, [initImageId, firebaseUid, controller, isEditorReady, loadImageFromId]);
|
|
416
|
-
useEffect(() => {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}, [currentImageId, isEditorReady]);
|
|
398
|
+
// useEffect(() => {
|
|
399
|
+
// // Ensure we have everything needed before trying to load.
|
|
400
|
+
// if (currentImageId && firebaseUid && controller && isEditorReady) {
|
|
401
|
+
// console.log(`[EFFECT] currentImageId changed to: ${currentImageId}. Loading new image into canvas.`);
|
|
402
|
+
// // Load the new image specified by the updated currentImageId
|
|
403
|
+
// loadImageFromId(firebaseUid, currentImageId);
|
|
404
|
+
// }
|
|
405
|
+
// }, [currentImageId, isEditorReady]);
|
|
424
406
|
const handleFileChange = (event) => {
|
|
425
407
|
const files = event.target?.files;
|
|
426
408
|
if (!files || files.length === 0)
|