Restore guest city summaries and refetch missing Pro details

This commit is contained in:
2569718930@qq.com
2026-04-08 18:25:25 +08:00
parent 951eb2f261
commit f108c9f7df
2 changed files with 138 additions and 2 deletions
+46
View File
@@ -344,6 +344,39 @@ export function DashboardStoreProvider({
return detail;
};
useEffect(() => {
if (proAccess.loading) return;
if (!selectedCity) return;
if (!isPanelOpen) return;
if (!proAccess.authenticated || !proAccess.subscriptionActive) return;
if (cityDetailsByName[selectedCity]) return;
let cancelled = false;
setLoadingState((current) => ({ ...current, cityDetail: true }));
void ensureCityDetail(selectedCity, false)
.then((detail) => {
if (cancelled) return;
setSelectedForecastDate(detail.local_date);
})
.catch(() => {})
.finally(() => {
if (cancelled) return;
setLoadingState((current) => ({ ...current, cityDetail: false }));
});
return () => {
cancelled = true;
};
}, [
cityDetailsByName,
ensureCityDetail,
isPanelOpen,
proAccess.authenticated,
proAccess.loading,
proAccess.subscriptionActive,
selectedCity,
]);
const ensureCityMarketScan = async (
cityName: string,
force = false,
@@ -526,6 +559,19 @@ export function DashboardStoreProvider({
await refreshProAccess();
}
const access = proAccessRef.current;
if (!access.authenticated || !access.subscriptionActive) {
if (!citySummariesRef.current[cityName]) {
try {
const summary = await dashboardClient.getCitySummary(cityName);
setCitySummariesByName((current) => ({
...current,
[cityName]: summary,
}));
} catch {}
}
return;
}
const cachedDetail = cityDetailsByName[cityName];
const needsDetailRefresh = hasSparseDetailCoverage(
cachedDetail,