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