Fix new reviews not going away

This commit is contained in:
Nicolas Mowen 2024-03-07 06:03:32 -07:00
parent 7f940cf29b
commit f8ee5cc953
2 changed files with 10 additions and 2 deletions

View File

@ -8,19 +8,22 @@ type NewReviewDataProps = {
className: string;
contentRef: MutableRefObject<HTMLDivElement | null>;
severity: ReviewSeverity;
hasUpdate: boolean;
setHasUpdate: (update: boolean) => void;
pullLatestData: () => void;
};
export default function NewReviewData({
className,
contentRef,
severity,
hasUpdate,
setHasUpdate,
pullLatestData,
}: NewReviewDataProps) {
const { payload: review } = useFrigateReviews();
const startCheckTs = useMemo(() => Date.now() / 1000, []);
const [reviewTs, setReviewTs] = useState(startCheckTs);
const [hasUpdate, setHasUpdate] = useState(false);
useEffect(() => {
if (!review) {
@ -36,7 +39,7 @@ export default function NewReviewData({
if (reviewTs > startCheckTs) {
setHasUpdate(true);
}
}, [startCheckTs, reviewTs]);
}, [startCheckTs, reviewTs, setHasUpdate]);
return (
<div className={className}>

View File

@ -323,6 +323,8 @@ function DetectionReview({
// review interaction
const [hasUpdate, setHasUpdate] = useState(false);
const markAllReviewed = useCallback(async () => {
if (!currentItems) {
return;
@ -331,6 +333,7 @@ function DetectionReview({
await axios.post(`reviews/viewed`, {
ids: currentItems?.map((seg) => seg.id),
});
setHasUpdate(false);
pullLatestData();
}, [currentItems, pullLatestData]);
@ -424,6 +427,8 @@ function DetectionReview({
className="absolute w-full z-30"
contentRef={contentRef}
severity={severity}
hasUpdate={hasUpdate}
setHasUpdate={setHasUpdate}
pullLatestData={pullLatestData}
/>
)}