mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 11:11:12 -05:00
Add action_type to submission items
This commit is contained in:
@@ -133,17 +133,22 @@ async function detectPhotoChanges(submissionId: string): Promise<PhotoChange[]>
|
||||
* Detects what changed between original_data and item_data
|
||||
*/
|
||||
export async function detectChanges(
|
||||
item: { item_data?: any; original_data?: any; item_type: string },
|
||||
item: { item_data?: any; original_data?: any; item_type: string; action_type?: string },
|
||||
submissionId?: string
|
||||
): Promise<ChangesSummary> {
|
||||
const itemData = item.item_data || {};
|
||||
const originalData = item.original_data || {};
|
||||
|
||||
// Determine action type - special handling for photo_delete
|
||||
// Determine action type - prioritize explicit action_type field to preserve submission intent
|
||||
let action: 'create' | 'edit' | 'delete' = 'edit';
|
||||
|
||||
if (item.item_type === 'photo_delete' || itemData.action === 'delete' || itemData.deleted) {
|
||||
action = 'delete';
|
||||
} else if (item.action_type) {
|
||||
// Use explicit action_type if set (preserves original submission intent even after moderator edits)
|
||||
action = item.action_type as 'create' | 'edit' | 'delete';
|
||||
} else if (!originalData || Object.keys(originalData).length === 0) {
|
||||
// Fall back to inference for backwards compatibility
|
||||
action = 'create';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user