2.5.1
Slow down API calls to every 15mins on non-pro
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user