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);
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') {
setNearMeError('denied');
if (isNativeGeolocation()) {
@ -646,8 +652,10 @@ export default function MapPage() {
toast({
title: 'Location permission needed',
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',
duration: 12000,
});
} else {
// Web: show the browser re-enable help sheet.
@ -657,19 +665,24 @@ export default function MapPage() {
setNearMeError('timeout');
toast({
title: 'Location timed out',
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."
: 'Could not get your location in time. Check your signal and try again.',
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."
: 'Could not get your location in time. Check your signal and try again.') + diag,
variant: 'destructive',
duration: 12000,
});
} else {
setNearMeError('unavailable');
toast({
title: 'Location unavailable',
description: isNativeGeolocation()
? '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.',
description:
(isNativeGeolocation()
? '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.') +
diag,
variant: 'destructive',
duration: 12000,
});
}
}