mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-22 23:31:12 -05:00
Refactor: Suppress initial render transitions
This commit is contained in:
@@ -69,6 +69,7 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
|||||||
const [actionLoading, setActionLoading] = useState<string | null>(null);
|
const [actionLoading, setActionLoading] = useState<string | null>(null);
|
||||||
const [notes, setNotes] = useState<Record<string, string>>({});
|
const [notes, setNotes] = useState<Record<string, string>>({});
|
||||||
const [activeTab, setActiveTab] = useState<QueueTab>('mainQueue');
|
const [activeTab, setActiveTab] = useState<QueueTab>('mainQueue');
|
||||||
|
const [hasRenderedOnce, setHasRenderedOnce] = useState(false);
|
||||||
const [activeEntityFilter, setActiveEntityFilter] = useState<EntityFilter>('all');
|
const [activeEntityFilter, setActiveEntityFilter] = useState<EntityFilter>('all');
|
||||||
const [activeStatusFilter, setActiveStatusFilter] = useState<StatusFilter>('pending');
|
const [activeStatusFilter, setActiveStatusFilter] = useState<StatusFilter>('pending');
|
||||||
const [photoModalOpen, setPhotoModalOpen] = useState(false);
|
const [photoModalOpen, setPhotoModalOpen] = useState(false);
|
||||||
@@ -144,6 +145,15 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
|||||||
itemsRef.current = items;
|
itemsRef.current = items;
|
||||||
}, [items]);
|
}, [items]);
|
||||||
|
|
||||||
|
// Enable transitions after initial render
|
||||||
|
useEffect(() => {
|
||||||
|
if (!loading && items.length > 0 && !hasRenderedOnce) {
|
||||||
|
// Delay to ensure DOM has painted
|
||||||
|
const timer = setTimeout(() => setHasRenderedOnce(true), 100);
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}
|
||||||
|
}, [loading, items.length, hasRenderedOnce]);
|
||||||
|
|
||||||
const fetchItems = useCallback(async (entityFilter: EntityFilter = 'all', statusFilter: StatusFilter = 'pending', silent = false, tab: QueueTab = 'mainQueue') => {
|
const fetchItems = useCallback(async (entityFilter: EntityFilter = 'all', statusFilter: StatusFilter = 'pending', silent = false, tab: QueueTab = 'mainQueue') => {
|
||||||
if (!userRef.current) {
|
if (!userRef.current) {
|
||||||
return;
|
return;
|
||||||
@@ -1698,6 +1708,7 @@ export const ModerationQueue = forwardRef<ModerationQueueRef>((props, ref) => {
|
|||||||
isAdmin={isAdmin()}
|
isAdmin={isAdmin()}
|
||||||
isSuperuser={isSuperuser()}
|
isSuperuser={isSuperuser()}
|
||||||
queueIsLoading={queue.isLoading}
|
queueIsLoading={queue.isLoading}
|
||||||
|
isInitialRender={!hasRenderedOnce}
|
||||||
onNoteChange={handleNoteChange}
|
onNoteChange={handleNoteChange}
|
||||||
onApprove={handleModerationAction}
|
onApprove={handleModerationAction}
|
||||||
onResetToPending={handleResetToPending}
|
onResetToPending={handleResetToPending}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ interface QueueItemProps {
|
|||||||
isAdmin: boolean;
|
isAdmin: boolean;
|
||||||
isSuperuser: boolean;
|
isSuperuser: boolean;
|
||||||
queueIsLoading: boolean;
|
queueIsLoading: boolean;
|
||||||
|
isInitialRender?: boolean;
|
||||||
onNoteChange: (id: string, value: string) => void;
|
onNoteChange: (id: string, value: string) => void;
|
||||||
onApprove: (item: ModerationItem, action: 'approved' | 'rejected', notes?: string) => void;
|
onApprove: (item: ModerationItem, action: 'approved' | 'rejected', notes?: string) => void;
|
||||||
onResetToPending: (item: ModerationItem) => void;
|
onResetToPending: (item: ModerationItem) => void;
|
||||||
@@ -86,6 +87,7 @@ export const QueueItem = memo(({
|
|||||||
isAdmin,
|
isAdmin,
|
||||||
isSuperuser,
|
isSuperuser,
|
||||||
queueIsLoading,
|
queueIsLoading,
|
||||||
|
isInitialRender = false,
|
||||||
onNoteChange,
|
onNoteChange,
|
||||||
onApprove,
|
onApprove,
|
||||||
onResetToPending,
|
onResetToPending,
|
||||||
@@ -106,7 +108,7 @@ export const QueueItem = memo(({
|
|||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
key={item.id}
|
key={item.id}
|
||||||
className={`border-l-4 transition-opacity duration-200 ${
|
className={`border-l-4 ${!isInitialRender ? 'transition-opacity duration-200' : ''} ${
|
||||||
validationResult?.blockingErrors && validationResult.blockingErrors.length > 0 ? 'border-l-red-600' :
|
validationResult?.blockingErrors && validationResult.blockingErrors.length > 0 ? 'border-l-red-600' :
|
||||||
item.status === 'flagged' ? 'border-l-red-500' :
|
item.status === 'flagged' ? 'border-l-red-500' :
|
||||||
item.status === 'approved' ? 'border-l-green-500' :
|
item.status === 'approved' ? 'border-l-green-500' :
|
||||||
|
|||||||
Reference in New Issue
Block a user