@yogiswara/honcho-editor-ui 1.0.20 → 1.2.1

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.
@@ -7,7 +7,7 @@ declare global {
7
7
  }
8
8
  export interface Controller {
9
9
  onGetImage(firebaseUid: string, imageID: string): Promise<Gallery>;
10
- getImageList(firebaseUid: string): Promise<Gallery[]>;
10
+ getImageList(firebaseUid: string, eventId: string): Promise<Gallery[]>;
11
11
  syncConfig(firebaseUid: string): Promise<void>;
12
12
  handleBack(firebaseUid: string, imageID: string): void;
13
13
  getPresets(firebaseUid: string): Promise<Preset[]>;
@@ -38,7 +38,7 @@ export type ImageItem = {
38
38
  name: string;
39
39
  file: File;
40
40
  };
41
- export declare function useHonchoEditor(controller: Controller, initImageId: string, firebaseUid: string): {
41
+ export declare function useHonchoEditor(controller: Controller, initImageId: string, firebaseUid: string, eventId: string): {
42
42
  canvasRef: import("react").MutableRefObject<HTMLCanvasElement | null>;
43
43
  canvasContainerRef: import("react").MutableRefObject<HTMLDivElement | null>;
44
44
  fileInputRef: import("react").MutableRefObject<HTMLInputElement | null>;
@@ -6,7 +6,7 @@ const initialAdjustments = {
6
6
  whitesScore: 0, blacksScore: 0, saturationScore: 0, contrastScore: 0, clarityScore: 0, sharpnessScore: 0,
7
7
  };
8
8
  const clamp = (value) => Math.max(-100, Math.min(100, value));
9
- export function useHonchoEditor(controller, initImageId, firebaseUid) {
9
+ export function useHonchoEditor(controller, initImageId, firebaseUid, eventId) {
10
10
  const [currentImageId, setCurrentImageId] = useState(initImageId);
11
11
  // MARK: - Core Editor State & Refs
12
12
  const editorRef = useRef(null);
@@ -172,6 +172,29 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
172
172
  }, 50);
173
173
  return () => clearTimeout(timeoutId);
174
174
  }, [activeSubPanel, isBulkEditing]);
175
+ useEffect(() => {
176
+ const fetchAndSetImageList = async () => {
177
+ if (controller && firebaseUid && eventId && imageList.length === 0) {
178
+ try {
179
+ console.log("Hook is fetching image list for event:", eventId);
180
+ // The controller now requires eventId, adjust the interface if needed
181
+ const galleryList = await controller.getImageList(firebaseUid, eventId);
182
+ const items = galleryList.map(g => ({
183
+ id: g.id,
184
+ url: g.raw_edited?.path || g.download?.path || '',
185
+ name: g.uid,
186
+ file: new File([], g.id),
187
+ }));
188
+ setImageList(items);
189
+ console.log("Image list state updated in hook:", items);
190
+ }
191
+ catch (error) {
192
+ console.error("Hook failed to fetch image list:", error);
193
+ }
194
+ }
195
+ };
196
+ fetchAndSetImageList();
197
+ }, [controller, firebaseUid, eventId, imageList.length]);
175
198
  // Effect for keyboard shortcuts
176
199
  useEffect(() => {
177
200
  window.addEventListener('keydown', handleKeyDown);
@@ -310,6 +333,11 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
310
333
  }
311
334
  }
312
335
  }, [imageList, currentImageId]);
336
+ useEffect(() => {
337
+ if (initImageId) {
338
+ setCurrentImageId(initImageId);
339
+ }
340
+ }, [initImageId]);
313
341
  useEffect(() => {
314
342
  if (currentImageId && firebaseUid) {
315
343
  loadImageFromId(firebaseUid, currentImageId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yogiswara/honcho-editor-ui",
3
- "version": "1.0.20",
3
+ "version": "1.2.1",
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",