Allow free users to load city detail panels

This commit is contained in:
2569718930@qq.com
2026-04-16 00:30:12 +08:00
parent df82234b66
commit 4bfd2534bb
+5 -20
View File
@@ -310,14 +310,10 @@ export function DashboardStoreProvider({
); );
const citySummariesRef = useRef<Record<string, CitySummary>>({}); const citySummariesRef = useRef<Record<string, CitySummary>>({});
const selectedCityRef = useRef<string | null>(null); const selectedCityRef = useRef<string | null>(null);
const selectedDetail = const selectedDetail = selectedCity ? cityDetailsByName[selectedCity] || null : null;
selectedCity && proAccess.subscriptionActive
? cityDetailsByName[selectedCity] || null
: null;
useEffect(() => { useEffect(() => {
if (proAccess.loading) return; if (proAccess.loading) return;
if (!proAccess.authenticated || !proAccess.subscriptionActive) { if (!proAccess.authenticated || !proAccess.subscriptionActive) {
dashboardClient.clearCityDetailCache();
return; return;
} }
dashboardClient.writeCityDetailCacheBundle( dashboardClient.writeCityDetailCacheBundle(
@@ -376,8 +372,6 @@ export function DashboardStoreProvider({
if (proAccess.loading) return; if (proAccess.loading) return;
if (proAccess.authenticated && proAccess.subscriptionActive) return; if (proAccess.authenticated && proAccess.subscriptionActive) return;
dashboardClient.clearCityDetailCache(); dashboardClient.clearCityDetailCache();
setCityDetailsByName({});
setCityDetailMetaByName({});
}, [proAccess]); }, [proAccess]);
const scheduleBackgroundDetailRefresh = ( const scheduleBackgroundDetailRefresh = (
@@ -524,7 +518,6 @@ export function DashboardStoreProvider({
if (proAccess.loading) return; if (proAccess.loading) return;
if (!selectedCity) return; if (!selectedCity) return;
if (!isPanelOpen) return; if (!isPanelOpen) return;
if (!proAccess.authenticated || !proAccess.subscriptionActive) return;
if (cityDetailsByName[selectedCity]) return; if (cityDetailsByName[selectedCity]) return;
let cancelled = false; let cancelled = false;
@@ -724,18 +717,10 @@ export function DashboardStoreProvider({
setLoadingState((current) => ({ ...current, cityDetail: true })); setLoadingState((current) => ({ ...current, cityDetail: true }));
try { try {
await summaryPromise; await summaryPromise;
} catch { const detail = await ensureCityDetail(cityName, false, "panel");
} finally { if (selectedCityRef.current === cityName) {
setLoadingState((current) => ({ ...current, cityDetail: false })); setSelectedForecastDate(detail.local_date);
} }
return;
}
const access = proAccessRef.current;
if (!access.authenticated || !access.subscriptionActive) {
setLoadingState((current) => ({ ...current, cityDetail: true }));
try {
await summaryPromise;
} catch { } catch {
} finally { } finally {
setLoadingState((current) => ({ ...current, cityDetail: false })); setLoadingState((current) => ({ ...current, cityDetail: false }));