Slow down API calls to every 15mins on non-pro
This commit is contained in:
fraxle
2026-06-02 23:53:25 +01:00
parent 5a03077d9e
commit 06d611318e
2 changed files with 25 additions and 16 deletions
+14 -10
View File
@@ -52,7 +52,19 @@ export function useAppState() {
setLocation(loc);
};
const { forecast, airQuality, loading, error, now, fetchedAt } = useForecast(location);
// Pro tier flag is read early so useForecast can pick its refresh cadence
// (Pro: 5 min, free: 15 min). Full setup notes in the PRO TIER section below.
const [isPro, setIsPro] = useState(() => {
const params = new URLSearchParams(window.location.search);
if (params.get('pro') === '1') {
localStorage.setItem('sunscope_pro', '1');
window.history.replaceState({}, '', window.location.pathname);
return true;
}
return localStorage.getItem('sunscope_pro') === '1';
});
const { forecast, airQuality, loading, error, now, fetchedAt } = useForecast(location, isPro);
const [searchQuery, setSearchQuery] = useState('');
const [searchResults, setSearchResults] = useState([]);
@@ -109,15 +121,7 @@ export function useAppState() {
};
// ── 3. PRO TIER ──────────────────────────────────────────────────────
const [isPro, setIsPro] = useState(() => {
const params = new URLSearchParams(window.location.search);
if (params.get('pro') === '1') {
localStorage.setItem('sunscope_pro', '1');
window.history.replaceState({}, '', window.location.pathname);
return true;
}
return localStorage.getItem('sunscope_pro') === '1';
});
// (isPro is declared near the top so useForecast can read it; see above.)
// ── 4. PROFILE + COLUMN VISIBILITY ───────────────────────────────────
const [activeProfile, setActiveProfile] = useState(() => {