Fix: Token count UI doesn't re-render if it's open. (#4822)
This commit is contained in:
@@ -20,5 +20,5 @@ export interface Alert {
|
||||
compactButtonDisabled?: boolean;
|
||||
onCompact?: () => void;
|
||||
compactIcon?: React.ReactNode;
|
||||
autoCompactThreshold?: number; // Add this for showing the auto-compact threshold
|
||||
autoCompactThreshold?: number;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useRef, useEffect, useCallback, useState } from 'react';
|
||||
import { FaCircle } from 'react-icons/fa';
|
||||
import { isEqual } from 'lodash';
|
||||
import { cn } from '../../utils';
|
||||
import { Alert, AlertType } from '../alerts';
|
||||
import { AlertBox } from '../alerts';
|
||||
@@ -104,10 +105,10 @@ export default function BottomMenuAlertPopover({ alerts }: AlertPopoverProps) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Find new or changed alerts
|
||||
// Find new or changed alerts using deep comparison
|
||||
const changedAlerts = alerts.filter((alert, index) => {
|
||||
const prevAlert = previousAlertsRef.current[index];
|
||||
return !prevAlert || prevAlert.type !== alert.type || prevAlert.message !== alert.message;
|
||||
return !prevAlert || !isEqual(prevAlert, alert);
|
||||
});
|
||||
|
||||
previousAlertsRef.current = alerts;
|
||||
|
||||
Reference in New Issue
Block a user