Near Me: surface raw geolocation error text on-screen for diagnosis

Append the underlying native/browser error message to the failure toast
(and log it) with a 12s duration, so the exact failure reason is visible
on-device without needing adb. This lets us distinguish OS Location-off,
provider-unavailable, timeout, and plugin errors at a glance.

Co-authored-by: shakespeare.diy <assistant@shakespeare.diy>
This commit is contained in:
shakespeare.diy 2026-07-25 00:22:46 +07:00
parent 700ebee17e
commit 8870a3e07f

View file

@ -639,6 +639,12 @@ export default function MapPage() {
setNearMeLoading(false); setNearMeLoading(false);
const kind = err instanceof GeolocationError ? err.kind : 'unavailable'; const kind = err instanceof GeolocationError ? err.kind : 'unavailable';
// Raw diagnostic text so we can see exactly what failed on-device
// (no adb needed). Shown appended to the toast + logged.
const rawMsg = err instanceof Error ? err.message : String(err);
console.warn('[NearMe] geolocation failed:', kind, rawMsg, err);
const diag = rawMsg ? ` [${rawMsg}]` : '';
if (kind === 'denied') { if (kind === 'denied') {
setNearMeError('denied'); setNearMeError('denied');
if (isNativeGeolocation()) { if (isNativeGeolocation()) {
@ -646,8 +652,10 @@ export default function MapPage() {
toast({ toast({
title: 'Location permission needed', title: 'Location permission needed',
description: description:
'Allow location for SkateSpots in your device Settings → Apps → SkateSpots → Permissions, then tap Near Me again.', 'Allow location for SkateSpots in your device Settings → Apps → SkateSpots → Permissions, then tap Near Me again.' +
diag,
variant: 'destructive', variant: 'destructive',
duration: 12000,
}); });
} else { } else {
// Web: show the browser re-enable help sheet. // Web: show the browser re-enable help sheet.
@ -657,19 +665,24 @@ export default function MapPage() {
setNearMeError('timeout'); setNearMeError('timeout');
toast({ toast({
title: 'Location timed out', title: 'Location timed out',
description: isNativeGeolocation() description:
(isNativeGeolocation()
? "Couldn't get a location fix. Make sure Location/GPS is turned on in your phone's quick settings, then tap Near Me again." ? "Couldn't get a location fix. Make sure Location/GPS is turned on in your phone's quick settings, then tap Near Me again."
: 'Could not get your location in time. Check your signal and try again.', : 'Could not get your location in time. Check your signal and try again.') + diag,
variant: 'destructive', variant: 'destructive',
duration: 12000,
}); });
} else { } else {
setNearMeError('unavailable'); setNearMeError('unavailable');
toast({ toast({
title: 'Location unavailable', title: 'Location unavailable',
description: isNativeGeolocation() description:
(isNativeGeolocation()
? 'Turn on Location/GPS in your phone settings, allow location for SkateSpots (Settings → Apps → SkateSpots → Permissions), then try again.' ? 'Turn on Location/GPS in your phone settings, allow location for SkateSpots (Settings → Apps → SkateSpots → Permissions), then try again.'
: 'Your location could not be determined. Make sure location services are enabled.', : 'Your location could not be determined. Make sure location services are enabled.') +
diag,
variant: 'destructive', variant: 'destructive',
duration: 12000,
}); });
} }
} }