Location: say why it failed, retry once, show permission status
Publish Container / publish (push) Successful in 2m15s

The ⌖ button reported 'Location access denied' for every failure, including timeouts and
no-GPS-fix errors that have nothing to do with permission.

- Specific messages for denied / no fix / timeout, with the exact iPhone steps (Safari tab vs
  installed web app) and the error code for diagnosis
- One patient high-accuracy retry for slow or cold GPS fixes (a real denial is not retried)
- Live permission status line under the search row (allowed / not asked / blocked)
- Mentions Safari content blockers as a possible cause

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Nate EmmertandClaude Sonnet 5.5 committed 2026-10-15 15:07:19 -04:00
1 parent 0cbebfef2a
commit eaff2f55c8
4 files changed
+83 -8

No files matched your search

+31
View File
@@ -405,6 +405,36 @@ function centerMap(city, force) {
$('map-recenter-btn')?.addEventListener('click', () => { if (state.currentCity) centerMap(state.currentCity, true); });
})();
// ── Location permission status (so "blocked" is visible, not guessed) ────────
const GeoStatus = (() => {
const el = $('geo-status');
let status = null;
async function render() {
if (!el || !navigator.permissions || !navigator.geolocation) return;
try {
if (!status) {
status = await navigator.permissions.query({ name: 'geolocation' });
status.addEventListener('change', render);
}
} catch { return; }
const s = status.state;
const ios = /iPad|iPhone|iPod/.test(navigator.userAgent) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1);
const standalone = window.matchMedia('(display-mode: standalone)').matches || navigator.standalone === true;
if (s === 'granted') { el.className = 'geo-status ok'; el.textContent = '📍 Location: allowed. Tap ⌖ to use it.'; }
else if (s === 'prompt') { el.className = 'geo-status'; el.textContent = '📍 Location: not asked yet. Tap ⌖ and choose Allow when your phone asks.'; }
else if (s === 'denied') {
el.className = 'geo-status warn';
el.textContent = ios
? `📍 Location: your phone has this ${standalone ? 'app' : 'site'} set to Don't Allow. Fix it in Settings → Privacy & Security → Location Services → ${standalone ? '"NeCloud Weather"' : 'Safari Websites'}. A Safari content blocker can also do this: try aA → Turn Off Content Blockers.`
: '📍 Location: blocked for this site. Click the lock icon in the address bar → Location → Allow.';
} else { el.classList.add('hidden'); return; }
el.classList.remove('hidden');
}
render();
return { refresh: render };
})();
// ── Public hooks ─────────────────────────────────────────────────────────────
let lastOutlook = null;
window.AppUI = {
@@ -427,6 +457,7 @@ window.AppUI = {
if (stationFresh) renderStationContext();
},
centerMap,
refreshGeoStatus: () => GeoStatus.refresh(),
onAir(air) { renderAqi(air); },
refreshFx() { const c = $('sky-fx'); if (c && fx.kind) { cancelAnimationFrame(fx.raf); fxResize(c); fxSeed(fx.kind); if (fx.parts.length) fxFrame(performance.now()); } },
onStation() { syncTopbarLocation(); renderStationContext(); },