@yogiswara/honcho-editor-ui 3.4.16 → 3.4.17
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.
|
@@ -161,7 +161,6 @@ export function useHonchoEditorBulk(controller, eventID, firebaseUid) {
|
|
|
161
161
|
const currentAdjustments = useMemo(() => {
|
|
162
162
|
return getCurrentAdjustmentsForCopy(selectedIds, currentBatch);
|
|
163
163
|
}, [selectedIds, currentBatch]);
|
|
164
|
-
// Calculate active preset based on preset_id from history (not value comparison)
|
|
165
164
|
const areAdjustmentsEqual = (adj1, adj2) => {
|
|
166
165
|
// The fix is to use this more specific type for our keys array
|
|
167
166
|
const keys = [
|
|
@@ -177,38 +176,70 @@ export function useHonchoEditorBulk(controller, eventID, firebaseUid) {
|
|
|
177
176
|
}
|
|
178
177
|
return true;
|
|
179
178
|
};
|
|
179
|
+
// Calculate active preset based on preset_id from history (not value comparison)
|
|
180
180
|
const { activePreset, presetSummary } = useMemo(() => {
|
|
181
181
|
if (selectedIds.length === 0) {
|
|
182
182
|
return { activePreset: null, presetSummary: 'NO_SELECTION' };
|
|
183
183
|
}
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
184
|
+
const imageDetails = selectedIds.map(id => {
|
|
185
|
+
const adjustment = currentBatch.allImages[id];
|
|
186
|
+
const presetId = adjustment?.preset_id || null;
|
|
187
|
+
// Check if preset exists in our presets list
|
|
188
|
+
const matchingPreset = presetId ? presets.find(p => p.id === presetId) : null;
|
|
189
|
+
// Check if the adjustment values actually match the preset values
|
|
190
|
+
let hasValidMatchingPreset = false;
|
|
191
|
+
if (matchingPreset && adjustment) {
|
|
192
|
+
const presetAdjustments = presetToAdjustmentState(matchingPreset);
|
|
193
|
+
hasValidMatchingPreset = areAdjustmentsEqual(adjustment, presetAdjustments);
|
|
194
|
+
}
|
|
195
|
+
return {
|
|
196
|
+
imageId: id,
|
|
197
|
+
presetId,
|
|
198
|
+
matchingPreset,
|
|
199
|
+
hasValidMatchingPreset,
|
|
200
|
+
adjustmentValues: adjustment
|
|
201
|
+
};
|
|
202
|
+
});
|
|
203
|
+
console.log('Debug preset calculation (with custom check):', {
|
|
204
|
+
selectedIds,
|
|
205
|
+
imageDetails: imageDetails.map(detail => ({
|
|
206
|
+
imageId: detail.imageId,
|
|
207
|
+
presetId: detail.presetId,
|
|
208
|
+
presetName: detail.matchingPreset?.name || 'N/A',
|
|
209
|
+
hasValidMatchingPreset: detail.hasValidMatchingPreset,
|
|
210
|
+
isCustomAdjustment: detail.presetId && !detail.hasValidMatchingPreset
|
|
211
|
+
}))
|
|
212
|
+
});
|
|
213
|
+
// Get images that have ACTUALLY matching presets (not just preset IDs)
|
|
214
|
+
const imagesWithValidPresets = imageDetails.filter(detail => detail.hasValidMatchingPreset);
|
|
215
|
+
const validPresetIds = imagesWithValidPresets.map(detail => detail.presetId);
|
|
216
|
+
const uniqueValidPresetIds = new Set(validPresetIds);
|
|
217
|
+
// Case 1: No images have actually matching presets
|
|
218
|
+
// This includes: no preset_id, non-existent preset_id, or preset_id with modified values
|
|
219
|
+
if (imagesWithValidPresets.length === 0) {
|
|
220
|
+
console.log('Case 1: No images have valid matching presets - showing Select');
|
|
188
221
|
return { activePreset: null, presetSummary: 'NO_SELECTION' };
|
|
189
222
|
}
|
|
190
|
-
// Case 2:
|
|
191
|
-
if (
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
// Case 3: All have the SAME preset ID. Now we must verify the adjustments.
|
|
195
|
-
const singlePresetId = presetIds[0];
|
|
196
|
-
if (typeof singlePresetId !== 'string') {
|
|
223
|
+
// Case 2: Some images have valid matching presets, some don't (mixed state)
|
|
224
|
+
if (imagesWithValidPresets.length > 0 && imagesWithValidPresets.length < selectedIds.length) {
|
|
225
|
+
console.log('Case 2: Mixed preset state (some valid, some custom/none) - showing Multiple presets');
|
|
197
226
|
return { activePreset: null, presetSummary: 'MULTIPLE_PRESETS' };
|
|
198
227
|
}
|
|
199
|
-
|
|
200
|
-
if (
|
|
228
|
+
// Case 3: All images have valid matching presets, but different ones
|
|
229
|
+
if (uniqueValidPresetIds.size > 1) {
|
|
230
|
+
console.log('Case 3: Multiple different valid presets - showing Multiple presets');
|
|
201
231
|
return { activePreset: null, presetSummary: 'MULTIPLE_PRESETS' };
|
|
202
232
|
}
|
|
203
|
-
//
|
|
204
|
-
const
|
|
205
|
-
const
|
|
206
|
-
if (
|
|
207
|
-
|
|
233
|
+
// Case 4: All images have the same valid matching preset
|
|
234
|
+
const singleValidPresetId = Array.from(uniqueValidPresetIds)[0];
|
|
235
|
+
const matchingPreset = presets.find(p => p.id === singleValidPresetId);
|
|
236
|
+
if (matchingPreset) {
|
|
237
|
+
console.log('Case 4: All images have the same valid matching preset');
|
|
208
238
|
return { activePreset: matchingPreset, presetSummary: 'SINGLE' };
|
|
209
239
|
}
|
|
210
240
|
else {
|
|
211
|
-
// This
|
|
241
|
+
// This shouldn't happen given our filtering above, but safety check
|
|
242
|
+
console.log('Case 4 safety check failed - showing Select');
|
|
212
243
|
return { activePreset: null, presetSummary: 'NO_SELECTION' };
|
|
213
244
|
}
|
|
214
245
|
}, [selectedIds, currentBatch.allImages, presets]);
|