refactor: NPED Context, sound update and start session

This commit is contained in:
2025-09-25 10:38:49 +01:00
parent efd037754e
commit 80b407943f
20 changed files with 96 additions and 39 deletions

View File

@@ -15,6 +15,7 @@ import NPED_CAT_B from "/NPED_Cat_B.svg";
import NPED_CAT_C from "/NPED_Cat_C.svg";
import popup from "../../assets/sounds/ui/popup_open.mp3";
import { useSound } from "react-sounds";
import { useNPEDContext } from "../../context/NPEDUserContext";
function useNow(tickMs = 1000) {
const [, setNow] = useState(() => Date.now());
@@ -46,9 +47,18 @@ export default function SightingHistoryWidget({
setSightingModalOpen,
isSightingModalOpen,
selectedSighting,
mostRecent,
} = useSightingFeedContext();
const { dispatch } = useAlertHitContext();
const { sessionStarted, setSessionList, sessionList } = useNPEDContext();
useEffect(() => {
if (sessionStarted) {
if (!mostRecent) return;
setSessionList([...sessionList, mostRecent]);
}
}, [mostRecent, sessionStarted, setSessionList]);
const hasAutoOpenedRef = useRef(false);
@@ -84,10 +94,11 @@ export default function SightingHistoryWidget({
useEffect(() => {
if (hasAutoOpenedRef.current) return;
const firstHot = rows?.find((r) => {
const isHotListHit = r?.metadata?.hotlistMatches?.Hotlist0 === true;
const isNPEDHitA = r?.metadata?.npedJSON?.["NPED CATEGORY"] === "A";
const isNPEDHitB = r?.metadata?.npedJSON?.["NPED CATEGORY"] === "B";
const isNPEDHitC = r?.metadata?.npedJSON?.["NPED CATEGORY"] === "C";
return isNPEDHitA || isNPEDHitB || isNPEDHitC;
return isNPEDHitA || isNPEDHitB || isNPEDHitC || isHotListHit;
});
if (firstHot) {
setSelectedSighting(firstHot);