updated image loading
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user