@yogiswara/honcho-editor-ui 2.1.6 → 2.1.7
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.
|
@@ -4,15 +4,16 @@ import { useAdjustmentHistory } from '../useAdjustmentHistory';
|
|
|
4
4
|
import { useAdjustmentHistoryBatch } from '../useAdjustmentHistoryBatch';
|
|
5
5
|
// Helper function to map the API response to the format our UI component needs
|
|
6
6
|
const mapGalleryToPhotoData = (gallery) => {
|
|
7
|
-
|
|
7
|
+
// Use thumbnail as the primary source, with fallbacks for safety
|
|
8
|
+
const bestImage = gallery.thumbnail || gallery.download || { path: '', width: 1, height: 1, key: gallery.id, size: 0 };
|
|
8
9
|
return {
|
|
9
10
|
key: gallery.id,
|
|
10
|
-
src:
|
|
11
|
-
original: gallery.download?.path ||
|
|
12
|
-
width:
|
|
13
|
-
height:
|
|
11
|
+
src: bestImage.path,
|
|
12
|
+
original: gallery.download?.path || bestImage.path,
|
|
13
|
+
width: bestImage.width || 1,
|
|
14
|
+
height: bestImage.height || 1,
|
|
14
15
|
alt: gallery.id || 'gallery image',
|
|
15
|
-
isSelected: false,
|
|
16
|
+
isSelected: false, // Default to not selected
|
|
16
17
|
originalData: gallery,
|
|
17
18
|
};
|
|
18
19
|
};
|
|
@@ -162,28 +163,18 @@ export function useHonchoEditorBulk(controllerBulk, eventID, firebaseUid) {
|
|
|
162
163
|
setError(null);
|
|
163
164
|
controllerBulk.getImageList(firebaseUid, eventID, 1)
|
|
164
165
|
.then(response => {
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
const imageConfigs = images.map(img => ({
|
|
168
|
-
imageId: img.id,
|
|
169
|
-
adjustment: img.editor_config?.color_adjustment
|
|
170
|
-
? mapColorAdjustmentToAdjustmentState(img.editor_config.color_adjustment)
|
|
171
|
-
: initialAdjustments
|
|
172
|
-
}));
|
|
173
|
-
// Populate the batch history with all fetched images
|
|
174
|
-
batchActions.setSelection(imageConfigs);
|
|
175
|
-
// Immediately clear the selection so no images are selected by default
|
|
176
|
-
batchActions.clearSelection();
|
|
166
|
+
const mappedData = response.gallery.map(mapGalleryToPhotoData);
|
|
167
|
+
setImageCollection(mappedData);
|
|
177
168
|
})
|
|
178
169
|
.catch(err => {
|
|
179
|
-
console.error("Failed to fetch
|
|
180
|
-
setError(
|
|
170
|
+
console.error("Failed to fetch image list:", err);
|
|
171
|
+
setError("Could not load images.");
|
|
181
172
|
})
|
|
182
173
|
.finally(() => {
|
|
183
174
|
setIsLoading(false);
|
|
184
175
|
});
|
|
185
176
|
}
|
|
186
|
-
}, [eventID, firebaseUid, controllerBulk
|
|
177
|
+
}, [eventID, firebaseUid, controllerBulk]);
|
|
187
178
|
return {
|
|
188
179
|
imageCollection,
|
|
189
180
|
isSelectedMode,
|