mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 11:51:14 -05:00
Fix auto-refresh and queue claiming
This commit is contained in:
@@ -7,11 +7,12 @@ import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert';
|
||||
import { supabase } from '@/integrations/supabase/client';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { useUserRole } from '@/hooks/useUserRole';
|
||||
import { useAuth } from '@/hooks/useAuth';
|
||||
import { format } from 'date-fns';
|
||||
import { format, formatDistance } from 'date-fns';
|
||||
import { PhotoModal } from './PhotoModal';
|
||||
import { SubmissionReviewManager } from './SubmissionReviewManager';
|
||||
import { useIsMobile } from '@/hooks/use-mobile';
|
||||
@@ -366,6 +367,17 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
||||
|
||||
// If there are changes and we should preserve interaction
|
||||
if (mergeResult.hasChanges) {
|
||||
// Debug logging for smart merge
|
||||
console.log('🔄 Smart merge detected changes:', {
|
||||
added: mergeResult.changes.added.length,
|
||||
updated: mergeResult.changes.updated.length,
|
||||
removed: mergeResult.changes.removed.length,
|
||||
newItemsCount: mergeResult.changes.added.length,
|
||||
protectedIds: Array.from(preserveInteraction ? interactingWith : new Set<string>()),
|
||||
strategy: refreshStrategy,
|
||||
preserveInteraction
|
||||
});
|
||||
|
||||
// Filter out items user is interacting with
|
||||
const protectedIds = preserveInteraction ? interactingWith : new Set<string>();
|
||||
const mergedWithProtection = mergeResult.items.map(item => {
|
||||
@@ -2027,21 +2039,40 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* New Items Notification */}
|
||||
{/* Auto-refresh Status Indicator */}
|
||||
{refreshMode === 'auto' && (
|
||||
<div className="flex items-center gap-2 text-xs text-muted-foreground px-1">
|
||||
<div className="flex items-center gap-1">
|
||||
<div className="w-2 h-2 rounded-full bg-green-500 animate-pulse" />
|
||||
<span>Auto-refresh active</span>
|
||||
</div>
|
||||
<span>•</span>
|
||||
<span>Checking every {Math.round(pollInterval / 1000)}s</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* New Items Notification - Enhanced */}
|
||||
{newItemsCount > 0 && (
|
||||
<div className="flex items-center justify-center">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
setNewItemsCount(0);
|
||||
fetchItems(activeEntityFilter, activeStatusFilter, false);
|
||||
}}
|
||||
className="flex items-center gap-2 border-primary/50 bg-primary/5 hover:bg-primary/10"
|
||||
>
|
||||
<RefreshCw className="w-4 h-4" />
|
||||
Show {newItemsCount} new {newItemsCount === 1 ? 'item' : 'items'}
|
||||
</Button>
|
||||
<div className="sticky top-0 z-10 animate-in fade-in-50">
|
||||
<Alert className="border-primary/50 bg-primary/5">
|
||||
<AlertCircle className="h-4 w-4 animate-pulse" />
|
||||
<AlertTitle>New Items Available</AlertTitle>
|
||||
<AlertDescription className="flex items-center justify-between">
|
||||
<span>{newItemsCount} new {newItemsCount === 1 ? 'submission' : 'submissions'} pending review</span>
|
||||
<Button
|
||||
variant="default"
|
||||
size="sm"
|
||||
onClick={() => {
|
||||
setNewItemsCount(0);
|
||||
fetchItems(activeEntityFilter, activeStatusFilter, false);
|
||||
}}
|
||||
className="ml-4"
|
||||
>
|
||||
<RefreshCw className="w-4 h-4 mr-2" />
|
||||
Show New Items
|
||||
</Button>
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user