added nped list functionality

This commit is contained in:
2025-08-29 14:55:37 +01:00
parent d2b8827987
commit 4fd3bd4319
15 changed files with 152 additions and 39 deletions

View File

@@ -6,6 +6,7 @@ import { useQuery } from "@tanstack/react-query";
async function fetchSighting(url: string, ref: number, signal?: AbortSignal) {
const dynamicUrl = `${url}${ref}`;
const res = await fetch(dynamicUrl, { signal });
if (!res.ok) throw new Error(String(res.status));
return (await res.json()) as SightingWidgetType;
@@ -20,12 +21,13 @@ export function useSightingFeed(url: string) {
const [mostRecent, setMostRecent] = useState<SightingWidgetType | null>(null);
const mostRecentRef = useRef<number>(-1);
const lastSeenRef = useRef<number | null>(null);
const { data, isPending } = useQuery({
queryKey: ["sighting"],
queryFn: ({ signal }) => fetchSighting(url, mostRecentRef.current, signal),
refetchInterval: 200,
refetchInterval: 2000,
refetchIntervalInBackground: true,
refetchOnWindowFocus: false,
staleTime: 0,