@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.
@@ -35,7 +35,6 @@ export type Preset = {
35
35
  export type ImageItem = {
36
36
  id: string;
37
37
  url: string;
38
- name: string;
39
38
  file: File;
40
39
  };
41
40
  export declare function useHonchoEditor(controller: Controller, initImageId: string, firebaseUid: string, eventId: string): {
@@ -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
- if (initImageId) {
338
- setCurrentImageId(initImageId);
339
- }
340
- }, [initImageId]);
341
- useEffect(() => {
342
- if (currentImageId && firebaseUid) {
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
- }, [currentImageId, firebaseUid, loadImageFromId]);
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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yogiswara/honcho-editor-ui",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "A complete UI component library for the Honcho photo editor.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",