@yogiswara/honcho-editor-ui 1.2.1 → 1.2.2
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.
|
@@ -334,15 +334,25 @@ export function useHonchoEditor(controller, initImageId, firebaseUid, eventId) {
|
|
|
334
334
|
}
|
|
335
335
|
}, [imageList, currentImageId]);
|
|
336
336
|
useEffect(() => {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
loadImageFromId(firebaseUid, currentImageId);
|
|
337
|
+
// This is now the single point of control for loading an image based on the initial props.
|
|
338
|
+
// 1. First, check if all conditions are met to even attempt loading.
|
|
339
|
+
// We ensure the editor itself is ready before doing anything.
|
|
340
|
+
const canLoad = initImageId && firebaseUid && controller && isEditorReady;
|
|
341
|
+
if (!canLoad) {
|
|
342
|
+
return;
|
|
344
343
|
}
|
|
345
|
-
|
|
344
|
+
// 2. Define the loading sequence as an async function inside the effect.
|
|
345
|
+
const loadInitialImage = async () => {
|
|
346
|
+
console.log(`[EFFECT] Starting to load initial image ID: ${initImageId}`);
|
|
347
|
+
// This directly calls the loading function. We don't need to set
|
|
348
|
+
// an intermediate 'currentImageId' state, which avoids an extra re-render and potential loop.
|
|
349
|
+
await loadImageFromId(firebaseUid, initImageId);
|
|
350
|
+
};
|
|
351
|
+
// 3. Execute the loading sequence.
|
|
352
|
+
loadInitialImage();
|
|
353
|
+
// Dependencies: The external props and readiness flags that trigger this logic.
|
|
354
|
+
// Whenever any of these change, this effect will re-evaluate.
|
|
355
|
+
}, [initImageId, firebaseUid, controller, isEditorReady, loadImageFromId]);
|
|
346
356
|
const handleFileChange = (event) => {
|
|
347
357
|
const files = event.target?.files;
|
|
348
358
|
if (!files || files.length === 0)
|