Refactor: Use admin settings for queue refresh

This commit is contained in:
gpt-engineer-app[bot]
2025-10-09 12:45:28 +00:00
parent 732efa9992
commit c79b12da76

View File

@@ -422,12 +422,12 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
});
setSubmissionMemo(newMemoMap);
// CRM-style frozen queue logic using refs
// CRM-style frozen queue logic using admin settings
const currentRefreshStrategy = refreshStrategyRef.current;
const currentPreserveInteraction = preserveInteractionRef.current;
if (silent) {
// Background polling: ONLY detect NEW submissions, never update existing ones
// Background polling: behavior controlled by admin settings
const currentLoadedIds = loadedIdsRef.current;
const newSubmissions = moderationItems.filter(item => !currentLoadedIds.has(item.id));
@@ -450,8 +450,38 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
});
}
// DON'T update items array during background polling - queue stays frozen
console.log('✅ Queue frozen - existing submissions unchanged');
// Apply refresh strategy from admin settings
switch (currentRefreshStrategy) {
case 'notify':
// Only show notification count, never modify queue
console.log('✅ Queue frozen (notify mode) - existing submissions unchanged');
break;
case 'merge':
// Add new items to end of existing queue
if (newSubmissions.length > 0) {
setItems(prev => [...prev, ...newSubmissions]);
console.log('🔀 Queue merged - added', newSubmissions.length, 'new items');
} else {
console.log('✅ Queue frozen (merge mode) - no new items to add');
}
break;
case 'replace':
// Full refresh: replace entire queue
setItems(moderationItems);
if (!currentPreserveInteraction) {
// Reset interaction state if not preserving
setPendingNewItems([]);
setNewItemsCount(0);
}
console.log('🔄 Queue replaced (replace mode) - full refresh with', moderationItems.length, 'items');
break;
default:
// Fallback to frozen behavior
console.log('✅ Queue frozen (default) - existing submissions unchanged');
}
} else {
// Normal fetch: Load all items and reset pending
setItems(moderationItems);