mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 11:51:14 -05:00
Refactor: Use admin settings for queue refresh
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user