Add video feed feature with related components and hooks

- Implemented VideoFeed component to display sightings.
- Created useSightingList and useVideoFeed hooks for data fetching and state management.
- Added AppProviders for context management.
- Updated Dashboard to include VideoFeed.
- Introduced types for sightings in utils/types.tsx.
- Added Header and Footer components for layout.
- Configured React Query for data handling.
This commit is contained in:
2025-12-19 16:04:06 +00:00
parent c38e3439e2
commit 276dcd26ed
18 changed files with 194 additions and 5 deletions

View File

@@ -0,0 +1,26 @@
import { useEffect, useRef, useState } from "react";
import { useVideoFeed } from "./useVideoFeed";
import type { SightingType } from "../../../utils/types";
export const useSightingList = () => {
const [sightingList, setSightingList] = useState<SightingType[]>([]);
const { videoFeedQuery } = useVideoFeed();
const latestSighting = videoFeedQuery?.data;
const lastProcessedRef = useRef<number>(-1);
useEffect(() => {
if (!latestSighting || latestSighting.ref === undefined || latestSighting.ref === -1) return;
if (latestSighting.ref !== lastProcessedRef.current) {
lastProcessedRef.current = latestSighting.ref;
// eslint-disable-next-line react-hooks/set-state-in-effect
setSightingList((prevList) => {
if (prevList[0]?.ref === latestSighting.ref) return prevList;
const dedupPrev = prevList.filter((s) => s.ref !== latestSighting.ref);
return [latestSighting, ...dedupPrev].slice(0, 10);
});
}
}, [latestSighting, latestSighting?.ref]);
return { sightingList };
};