Make city clicks update homepage focus
This commit is contained in:
@@ -251,7 +251,7 @@ export function CitySidebar() {
|
||||
className={clsx("city-item", isActive && "active")}
|
||||
onClick={() =>
|
||||
startTransition(() => {
|
||||
void store.selectCity(city.name);
|
||||
void store.focusCity(city.name);
|
||||
})
|
||||
}
|
||||
>
|
||||
|
||||
@@ -16,7 +16,7 @@ export function MapCanvas() {
|
||||
onMapInteractionChange: store.setMapInteractionActive,
|
||||
onRegisterStopMotion: store.registerMapStopMotion,
|
||||
onSelectCity: (cityName) => {
|
||||
void store.selectCity(cityName);
|
||||
void store.focusCity(cityName);
|
||||
},
|
||||
selectedCity: store.selectedCity,
|
||||
selectedDetail: store.selectedDetail,
|
||||
|
||||
@@ -280,7 +280,7 @@ function OpportunityStrip({ snapshots }: { snapshots: CitySnapshot[] }) {
|
||||
key={city.name}
|
||||
type="button"
|
||||
className="opportunity-card"
|
||||
onClick={() => void store.selectCity(city.name)}
|
||||
onClick={() => void store.focusCity(city.name)}
|
||||
>
|
||||
<span className={clsx("opportunity-risk-dot", String(tier || "other"))} />
|
||||
<span className="opportunity-city">{city.display_name}</span>
|
||||
|
||||
@@ -41,6 +41,7 @@ interface DashboardStoreValue extends DashboardState {
|
||||
force?: boolean,
|
||||
depth?: "panel" | "nearby" | "full",
|
||||
) => Promise<CityDetail>;
|
||||
focusCity: (cityName: string) => Promise<void>;
|
||||
forecastModalMode: ForecastModalMode | null;
|
||||
futureModalDate: string | null;
|
||||
loadCities: () => Promise<void>;
|
||||
@@ -804,6 +805,15 @@ export function DashboardStoreProvider({
|
||||
});
|
||||
};
|
||||
|
||||
const focusCity = async (cityName: string) => {
|
||||
setSelectedCity(cityName);
|
||||
setIsPanelOpen(false);
|
||||
setSelectedForecastDate(null);
|
||||
setFutureModalDate(null);
|
||||
setForecastModalMode(null);
|
||||
void ensureCitySummary(cityName).catch(() => null);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window === "undefined") return;
|
||||
if (selectedCity) {
|
||||
@@ -1016,6 +1026,7 @@ export function DashboardStoreProvider({
|
||||
setIsPanelOpen(false);
|
||||
},
|
||||
ensureCityDetail,
|
||||
focusCity,
|
||||
forecastModalMode,
|
||||
futureModalDate,
|
||||
historyState,
|
||||
|
||||
Reference in New Issue
Block a user