@yogiswara/honcho-editor-ui 3.8.0 → 3.8.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.
|
@@ -12,6 +12,14 @@ export interface PhotoData {
|
|
|
12
12
|
isSelected: boolean;
|
|
13
13
|
adjustments?: Partial<AdjustmentValues>;
|
|
14
14
|
}
|
|
15
|
+
export interface GalleryDataProps {
|
|
16
|
+
photos: any[];
|
|
17
|
+
isLoading: boolean;
|
|
18
|
+
isLoadingMore: boolean;
|
|
19
|
+
hasMore: boolean;
|
|
20
|
+
loadMore: () => void;
|
|
21
|
+
reloadGallery: () => void;
|
|
22
|
+
}
|
|
15
23
|
export interface CopyCheckboxes {
|
|
16
24
|
color: {
|
|
17
25
|
temperature: boolean;
|
|
@@ -155,4 +163,4 @@ export interface UseHonchoEditorBulkReturn {
|
|
|
155
163
|
* - Automatic backend synchronization for all state changes
|
|
156
164
|
* - Comprehensive logging of multi-image operations
|
|
157
165
|
*/
|
|
158
|
-
export declare function useHonchoEditorBulk(controller: Controller, eventID: string, firebaseUid: string): UseHonchoEditorBulkReturn;
|
|
166
|
+
export declare function useHonchoEditorBulk(controller: Controller, eventID: string, firebaseUid: string, galleryHookData: GalleryDataProps): UseHonchoEditorBulkReturn;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useState, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
3
3
|
import { useAdjustmentHistoryBatch } from '../useAdjustmentHistoryBatch';
|
|
4
|
-
import { usePaging } from "../usePaging";
|
|
5
4
|
import { usePreset } from "../usePreset";
|
|
6
5
|
import { mapAdjustmentStateToAdjustmentEditor } from "../../utils/adjustment";
|
|
7
6
|
import { log } from '../../utils/logger';
|
|
@@ -142,13 +141,16 @@ const getCurrentAdjustmentsForCopy = (selectedIds, currentBatch) => {
|
|
|
142
141
|
* - Automatic backend synchronization for all state changes
|
|
143
142
|
* - Comprehensive logging of multi-image operations
|
|
144
143
|
*/
|
|
145
|
-
export function useHonchoEditorBulk(controller, eventID, firebaseUid) {
|
|
144
|
+
export function useHonchoEditorBulk(controller, eventID, firebaseUid, galleryHookData) {
|
|
146
145
|
const { state, actions: batchActions } = useAdjustmentHistoryBatch(controller, firebaseUid, eventID);
|
|
147
146
|
const { currentBatch, selectedIds } = state;
|
|
148
|
-
const { images, info, actions } = usePaging(controller, firebaseUid, eventID, {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
});
|
|
147
|
+
// const { images, info, actions } = usePaging(controller, firebaseUid, eventID, {
|
|
148
|
+
// autoLoad: true,
|
|
149
|
+
// autoReset: false, // Prevent auto-reset to avoid loops
|
|
150
|
+
// });
|
|
151
|
+
const images = useMemo(() => {
|
|
152
|
+
return galleryHookData.photos.map(p => p.value || p);
|
|
153
|
+
}, [galleryHookData.photos]);
|
|
152
154
|
// Preset management
|
|
153
155
|
const { presets, info: presetInfo, actions: presetActions } = usePreset(controller, firebaseUid, {
|
|
154
156
|
autoLoad: true,
|
|
@@ -178,12 +180,12 @@ export function useHonchoEditorBulk(controller, eventID, firebaseUid) {
|
|
|
178
180
|
};
|
|
179
181
|
const readyState = useMemo(() => {
|
|
180
182
|
const paging = {
|
|
181
|
-
isReady:
|
|
182
|
-
isLoading:
|
|
183
|
+
isReady: !galleryHookData.isLoading, // Simplified ready check
|
|
184
|
+
isLoading: galleryHookData.isLoading,
|
|
183
185
|
};
|
|
184
186
|
log.debug("[useHonchoEditorBulk] 📊 Paging state");
|
|
185
187
|
const history = {
|
|
186
|
-
isReady: state.isReady ?? true,
|
|
188
|
+
isReady: state.isReady ?? true,
|
|
187
189
|
isLoading: state.isLoading ?? false
|
|
188
190
|
};
|
|
189
191
|
log.debug("[useHonchoEditorBulk] 📊 History state");
|
|
@@ -191,26 +193,15 @@ export function useHonchoEditorBulk(controller, eventID, firebaseUid) {
|
|
|
191
193
|
isReady: presetInfo.isReady ?? (presetInfo.isInitialized && !presetInfo.isLoading),
|
|
192
194
|
isLoading: presetInfo.isLoading
|
|
193
195
|
};
|
|
194
|
-
log.debug("[useHonchoEditorBulk] 📊 Preset state");
|
|
195
196
|
const allReady = paging.isReady && history.isReady && presets.isReady;
|
|
196
197
|
const anyLoading = paging.isLoading || history.isLoading || presets.isLoading;
|
|
197
|
-
log.debug({
|
|
198
|
-
paging: { isReady: paging.isReady, isLoading: paging.isLoading },
|
|
199
|
-
history: { isReady: history.isReady, isLoading: history.isLoading },
|
|
200
|
-
presets: { isReady: presets.isReady, isLoading: presets.isLoading },
|
|
201
|
-
allReady,
|
|
202
|
-
anyLoading
|
|
203
|
-
}, '[useHonchoEditorBulk] 📊 Ready state computed');
|
|
204
198
|
return {
|
|
205
199
|
isReady: allReady,
|
|
206
200
|
isLoading: anyLoading,
|
|
207
201
|
operations: { paging, history, presets }
|
|
208
202
|
};
|
|
209
203
|
}, [
|
|
210
|
-
|
|
211
|
-
info.isInitialized,
|
|
212
|
-
info.isLoading,
|
|
213
|
-
info.error,
|
|
204
|
+
galleryHookData.isLoading, // Updated dependency
|
|
214
205
|
state.isReady,
|
|
215
206
|
state.isLoading,
|
|
216
207
|
presetInfo.isReady,
|
|
@@ -296,9 +287,9 @@ export function useHonchoEditorBulk(controller, eventID, firebaseUid) {
|
|
|
296
287
|
}, '[useHonchoEditorBulk] 🎨 Preset selection updated');
|
|
297
288
|
}, [activePreset]);
|
|
298
289
|
// Use loading states from usePaging instead of local state
|
|
299
|
-
const isLoading =
|
|
300
|
-
const error =
|
|
301
|
-
const hasMore =
|
|
290
|
+
const isLoading = galleryHookData.isLoading;
|
|
291
|
+
const error = null;
|
|
292
|
+
const hasMore = galleryHookData.hasMore;
|
|
302
293
|
const imageData = useMemo(() => {
|
|
303
294
|
const res = images.map(item => {
|
|
304
295
|
const basePhoto = mapGalleryToPhotoData(item, selectedIds);
|
|
@@ -536,7 +527,7 @@ export function useHonchoEditorBulk(controller, eventID, firebaseUid) {
|
|
|
536
527
|
return {
|
|
537
528
|
imageData,
|
|
538
529
|
isLoading,
|
|
539
|
-
isLoadingMore:
|
|
530
|
+
isLoadingMore: galleryHookData.isLoadingMore,
|
|
540
531
|
error,
|
|
541
532
|
selectedIds,
|
|
542
533
|
hasMore,
|
|
@@ -554,8 +545,8 @@ export function useHonchoEditorBulk(controller, eventID, firebaseUid) {
|
|
|
554
545
|
// Preset creation handlers
|
|
555
546
|
presetActions, // Expose preset actions for create/rename/delete
|
|
556
547
|
handleToggleImageSelection: batchActions.toggleSelection,
|
|
557
|
-
handleLoadMore:
|
|
558
|
-
handleRefresh:
|
|
548
|
+
handleLoadMore: async () => { galleryHookData.loadMore(); },
|
|
549
|
+
handleRefresh: async () => { galleryHookData.reloadGallery(); },
|
|
559
550
|
// Adjustment
|
|
560
551
|
handleBulkTempDecreaseMax,
|
|
561
552
|
handleBulkTempDecrease,
|