changes
This commit is contained in:
@@ -180,7 +180,21 @@ export class FusionClockKiosk extends Interaction {
|
||||
lat = pos.coords.latitude;
|
||||
lng = pos.coords.longitude;
|
||||
} catch {
|
||||
// GPS unavailable on kiosk device
|
||||
// Native GPS unavailable -- try IP geolocation
|
||||
}
|
||||
if (lat === 0 && lng === 0) {
|
||||
try {
|
||||
const ipResp = await fetch("https://ipapi.co/json/");
|
||||
if (ipResp.ok) {
|
||||
const ipData = await ipResp.json();
|
||||
if (ipData.latitude && ipData.longitude) {
|
||||
lat = ipData.latitude;
|
||||
lng = ipData.longitude;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// IP geolocation also unavailable
|
||||
}
|
||||
}
|
||||
|
||||
const resp = await fetch("/fusion_clock/kiosk/clock", {
|
||||
|
||||
@@ -199,15 +199,22 @@ export class FusionClockPortal extends Interaction {
|
||||
(pos) => {
|
||||
this._performClockAction(pos.coords.latitude, pos.coords.longitude, pos.coords.accuracy);
|
||||
},
|
||||
(err) => {
|
||||
async () => {
|
||||
let lat = 0, lng = 0;
|
||||
try {
|
||||
const ipResp = await fetch("https://ipapi.co/json/");
|
||||
if (ipResp.ok) {
|
||||
const ipData = await ipResp.json();
|
||||
if (ipData.latitude && ipData.longitude) {
|
||||
lat = ipData.latitude;
|
||||
lng = ipData.longitude;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// IP geolocation also unavailable
|
||||
}
|
||||
this._hideGPSOverlay();
|
||||
let msg = "Could not get your location. ";
|
||||
if (err.code === 1) msg += "Please allow location access.";
|
||||
else if (err.code === 2) msg += "Location unavailable.";
|
||||
else if (err.code === 3) msg += "Location request timed out.";
|
||||
this._showToast(msg, "error");
|
||||
this._shakeButton();
|
||||
btn.disabled = false;
|
||||
this._performClockAction(lat, lng, lat ? 5000 : 0);
|
||||
},
|
||||
{ enableHighAccuracy: true, timeout: 15000, maximumAge: 0 }
|
||||
);
|
||||
|
||||
@@ -398,10 +398,23 @@ export class FusionClockPortalFAB extends Interaction {
|
||||
lat = pos.coords.latitude;
|
||||
lng = pos.coords.longitude;
|
||||
acc = pos.coords.accuracy;
|
||||
} catch (geoErr) {
|
||||
this._showError("Location access denied. Please enable GPS.");
|
||||
if (this.actionBtn) this.actionBtn.disabled = false;
|
||||
return;
|
||||
} catch {
|
||||
// Native GPS unavailable (common on desktops) -- try IP geolocation
|
||||
}
|
||||
}
|
||||
if (lat === 0 && lng === 0) {
|
||||
try {
|
||||
const ipResp = await fetch("https://ipapi.co/json/");
|
||||
if (ipResp.ok) {
|
||||
const ipData = await ipResp.json();
|
||||
if (ipData.latitude && ipData.longitude) {
|
||||
lat = ipData.latitude;
|
||||
lng = ipData.longitude;
|
||||
acc = 5000;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// IP geolocation also unavailable
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -134,10 +134,23 @@ export class FusionClockFAB extends Component {
|
||||
lat = pos.coords.latitude;
|
||||
lng = pos.coords.longitude;
|
||||
acc = pos.coords.accuracy;
|
||||
} catch (geoErr) {
|
||||
this.state.error = "Location access denied.";
|
||||
this.state.loading = false;
|
||||
return;
|
||||
} catch {
|
||||
// Native GPS unavailable (common on desktops) -- try IP geolocation
|
||||
}
|
||||
}
|
||||
if (lat === 0 && lng === 0) {
|
||||
try {
|
||||
const ipResp = await fetch("https://ipapi.co/json/");
|
||||
if (ipResp.ok) {
|
||||
const ipData = await ipResp.json();
|
||||
if (ipData.latitude && ipData.longitude) {
|
||||
lat = ipData.latitude;
|
||||
lng = ipData.longitude;
|
||||
acc = 5000;
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
// IP geolocation also unavailable
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user