diff --git a/ui/src/components/layouts/MapLayout.tsx b/ui/src/components/layouts/MapLayout.tsx index 76493db2..b0a86af6 100644 --- a/ui/src/components/layouts/MapLayout.tsx +++ b/ui/src/components/layouts/MapLayout.tsx @@ -44,6 +44,7 @@ function MapLayout({ children }: { children: ReactNode }) { const [currentFeed, setCurrentFeed] = useState(feed); const [map, setMap] = useState(); const feeds = useFeedsQuery().data?.feeds ?? []; + const firstOnlineFeed = feeds.filter(({ online }) => online)[0]; // update the currentFeed only if there's a new feed useEffect(() => { @@ -52,7 +53,10 @@ function MapLayout({ children }: { children: ReactNode }) { map?.setZoom(9); map?.panTo(feed.latLng); } - }, [feed, map, currentFeed]); + if (!feed && !currentFeed && firstOnlineFeed) { + setCurrentFeed(firstOnlineFeed); + } + }, [feed, map, currentFeed, firstOnlineFeed]); const invalidateSize = () => { if (map) { diff --git a/ui/src/graphql/generated/index.ts b/ui/src/graphql/generated/index.ts index 8b341b67..b5435820 100644 --- a/ui/src/graphql/generated/index.ts +++ b/ui/src/graphql/generated/index.ts @@ -2338,6 +2338,8 @@ export type FeedsQuery = { imageUrl?: string | null; thumbUrl?: string | null; mapUrl?: string | null; + bucket: string; + online?: boolean | null; latLng: { __typename?: "LatLng"; lat: number; lng: number }; }>; }; @@ -3207,6 +3209,8 @@ export const FeedsDocument = ` imageUrl thumbUrl mapUrl + bucket + online } } `; diff --git a/ui/src/graphql/queries/listFeeds.graphql b/ui/src/graphql/queries/listFeeds.graphql index 5e11d32e..e962a870 100644 --- a/ui/src/graphql/queries/listFeeds.graphql +++ b/ui/src/graphql/queries/listFeeds.graphql @@ -11,5 +11,7 @@ query feeds { imageUrl thumbUrl mapUrl + bucket + online } }