updated image loading

This commit is contained in:
2025-08-22 10:38:28 +01:00
parent 44af1b21b7
commit 5ededd8e05
15 changed files with 258 additions and 120 deletions

View File

@@ -3,18 +3,20 @@ import type { SightingWidgetType } from "../types/types";
import { useSightingFeed } from "../hooks/useSightingFeed";
type SightingFeedContextType = {
items: (SightingWidgetType | null | undefined)[];
sightings: (SightingWidgetType | null | undefined)[];
selectedRef: number | null;
setSelectedRef: (ref: number | null) => void;
effectiveSelected: SightingWidgetType | null;
mostRecent: SightingWidgetType | null;
side: string;
isPending: boolean;
noSighting: boolean;
};
type SightingFeedProviderProps = {
baseUrl: string;
entries?: number;
pollMs?: number;
autoSelectLatest?: boolean;
url: string;
children: ReactNode;
side: string;
};
const SightingFeedContext = createContext<SightingFeedContextType | undefined>(
@@ -22,17 +24,32 @@ const SightingFeedContext = createContext<SightingFeedContextType | undefined>(
);
export const SightingFeedProvider = ({
baseUrl,
entries = 7,
pollMs = 500,
autoSelectLatest = true,
children,
url,
side,
}: SightingFeedProviderProps) => {
const { items, selectedRef, setSelectedRef, effectiveSelected } =
useSightingFeed(baseUrl, { limit: entries, pollMs, autoSelectLatest });
const {
sightings,
selectedRef,
setSelectedRef,
effectiveSelected,
mostRecent,
isPending,
noSighting,
} = useSightingFeed(url);
return (
<SightingFeedContext.Provider
value={{ items, selectedRef, setSelectedRef, effectiveSelected }}
value={{
sightings,
selectedRef,
setSelectedRef,
effectiveSelected,
mostRecent,
side,
isPending,
noSighting,
}}
>
{children}
</SightingFeedContext.Provider>