- updated state for tracking sessions
- removed un used state in sighting feed - added groupings depending on sightings
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import type { SightingType } from "../../types/types";
|
||||
import type { ReducedSightingType, SightingType } from "../../types/types";
|
||||
import { BLANK_IMG, getSoundFileURL } from "../../utils/utils";
|
||||
import NumberPlate from "../PlateStack/NumberPlate";
|
||||
import Card from "../UI/Card";
|
||||
@@ -61,10 +61,18 @@ export default function SightingHistoryWidget({
|
||||
const { dispatch } = useAlertHitContext();
|
||||
const { sessionStarted, setSessionList, sessionList } = useNPEDContext();
|
||||
|
||||
const reduceObject = (obj: SightingType): ReducedSightingType => {
|
||||
return {
|
||||
vrm: obj.vrm,
|
||||
metadata: obj?.metadata,
|
||||
};
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (sessionStarted) {
|
||||
if (!mostRecent) return;
|
||||
setSessionList([...sessionList, mostRecent]);
|
||||
const reducedMostRecent = reduceObject(mostRecent);
|
||||
setSessionList([...sessionList, reducedMostRecent]);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [mostRecent, sessionStarted, setSessionList]);
|
||||
|
||||
Reference in New Issue
Block a user