@yogiswara/honcho-editor-ui 3.4.14 → 3.4.16
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.
|
@@ -63,6 +63,7 @@ interface Props {
|
|
|
63
63
|
onSharpnessIncrease: () => void;
|
|
64
64
|
onSharpnessIncreaseMax: () => void;
|
|
65
65
|
selectedPresetBulk: string;
|
|
66
|
+
isPresetCreatedSet?: boolean;
|
|
66
67
|
onSelectPresetBulk: (id: string) => void;
|
|
67
68
|
onPresetMenuClickBulk: (event: React.MouseEvent<HTMLElement>, presetId: string) => void;
|
|
68
69
|
onOpenPresetModalBulk: () => void;
|
|
@@ -61,6 +61,7 @@ export declare function useHonchoEditorBulk(controller: Controller, eventID: str
|
|
|
61
61
|
presets: Preset[];
|
|
62
62
|
selectedBulkPreset: string;
|
|
63
63
|
activePreset: Preset | null;
|
|
64
|
+
presetSummary: string;
|
|
64
65
|
handleSelectBulkPreset: (presetId: string) => void;
|
|
65
66
|
clearSelection: () => void;
|
|
66
67
|
selectAllImages: () => void;
|
|
@@ -162,38 +162,55 @@ export function useHonchoEditorBulk(controller, eventID, firebaseUid) {
|
|
|
162
162
|
return getCurrentAdjustmentsForCopy(selectedIds, currentBatch);
|
|
163
163
|
}, [selectedIds, currentBatch]);
|
|
164
164
|
// Calculate active preset based on preset_id from history (not value comparison)
|
|
165
|
-
const
|
|
165
|
+
const areAdjustmentsEqual = (adj1, adj2) => {
|
|
166
|
+
// The fix is to use this more specific type for our keys array
|
|
167
|
+
const keys = [
|
|
168
|
+
'tempScore', 'tintScore', 'saturationScore', 'vibranceScore',
|
|
169
|
+
'exposureScore', 'contrastScore', 'highlightsScore', 'shadowsScore',
|
|
170
|
+
'whitesScore', 'blacksScore', 'clarityScore', 'sharpnessScore'
|
|
171
|
+
];
|
|
172
|
+
for (const key of keys) {
|
|
173
|
+
// Now, TypeScript knows `key` can't be 'preset_id', so adj1[key] will be a number.
|
|
174
|
+
if (Math.round(adj1[key] || 0) !== Math.round(adj2[key] || 0)) {
|
|
175
|
+
return false;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return true;
|
|
179
|
+
};
|
|
180
|
+
const { activePreset, presetSummary } = useMemo(() => {
|
|
166
181
|
if (selectedIds.length === 0) {
|
|
167
|
-
return null;
|
|
182
|
+
return { activePreset: null, presetSummary: 'NO_SELECTION' };
|
|
168
183
|
}
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
184
|
+
const presetIds = selectedIds.map(id => currentBatch.allImages[id]?.preset_id);
|
|
185
|
+
const uniquePresetIds = new Set(presetIds);
|
|
186
|
+
// Case 1: All selected images have NO preset.
|
|
187
|
+
if (uniquePresetIds.size === 1 && uniquePresetIds.has(undefined)) {
|
|
188
|
+
return { activePreset: null, presetSummary: 'NO_SELECTION' };
|
|
189
|
+
}
|
|
190
|
+
// Case 2: A mix of presets, or some with a preset and some without.
|
|
191
|
+
if (uniquePresetIds.size > 1) {
|
|
192
|
+
return { activePreset: null, presetSummary: 'MULTIPLE_PRESETS' };
|
|
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') {
|
|
197
|
+
return { activePreset: null, presetSummary: 'MULTIPLE_PRESETS' };
|
|
198
|
+
}
|
|
199
|
+
const matchingPreset = presets.find(p => p.id === singlePresetId);
|
|
200
|
+
if (!matchingPreset) {
|
|
201
|
+
return { activePreset: null, presetSummary: 'MULTIPLE_PRESETS' };
|
|
202
|
+
}
|
|
203
|
+
// THE FINAL VERIFICATION
|
|
204
|
+
const firstImageAdjustments = currentBatch.allImages[selectedIds[0]];
|
|
205
|
+
const presetAdjustments = presetToAdjustmentState(matchingPreset);
|
|
206
|
+
if (firstImageAdjustments && areAdjustmentsEqual(firstImageAdjustments, presetAdjustments)) {
|
|
207
|
+
// ID and adjustments match perfectly.
|
|
208
|
+
return { activePreset: matchingPreset, presetSummary: 'SINGLE' };
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
// This is a custom adjustment! The ID is there but the values don't match.
|
|
212
|
+
return { activePreset: null, presetSummary: 'NO_SELECTION' };
|
|
181
213
|
}
|
|
182
|
-
// Find the preset that matches the common preset_id
|
|
183
|
-
const matchingPreset = presets.find(preset => preset.id === firstPresetId);
|
|
184
|
-
log.debug({
|
|
185
|
-
selectedIds,
|
|
186
|
-
selectedPresetIds,
|
|
187
|
-
firstPresetId,
|
|
188
|
-
allSamePresetId,
|
|
189
|
-
matchingPreset: matchingPreset?.name || 'none',
|
|
190
|
-
selectedImageAdjustments: selectedIds.map(id => ({
|
|
191
|
-
imageId: id,
|
|
192
|
-
preset_id: currentBatch.allImages[id]?.preset_id,
|
|
193
|
-
hasAdjustment: !!currentBatch.allImages[id]
|
|
194
|
-
}))
|
|
195
|
-
}, '[useHonchoEditorBulk] 🎨 Active preset calculation');
|
|
196
|
-
return matchingPreset || null;
|
|
197
214
|
}, [selectedIds, currentBatch.allImages, presets]);
|
|
198
215
|
// Update selectedBulkPreset when activePreset changes
|
|
199
216
|
useEffect(() => {
|
|
@@ -458,6 +475,7 @@ export function useHonchoEditorBulk(controller, eventID, firebaseUid) {
|
|
|
458
475
|
presets,
|
|
459
476
|
selectedBulkPreset,
|
|
460
477
|
activePreset,
|
|
478
|
+
presetSummary,
|
|
461
479
|
handleSelectBulkPreset,
|
|
462
480
|
clearSelection,
|
|
463
481
|
selectAllImages,
|