[FIX] hr_attendance: work around geolocator for iOS

Versions
--------
- 17.0+

Steps
-----
1. Use iOS app;
2. click on red dot on top;
3. click check in.

Issue
-----
Nothing happens.

Cause
-----
The iOS app cannot request the user's location.

Commit 1acd0b6c5d attempted to fix this by
first checking whether `navigator.geolocation` exists, but the cause
is likely with its `getCurrentPosition` method instead of its existence.

Solution
--------
Instead of checking for `navigator.geolocation`, use `isIosApp` to skip
the geolocation part when using the iOS app.

opw-3734385

closes odoo/odoo#155588

Signed-off-by: Sofie Gvaladze (sgv) <sgv@odoo.com>
This commit is contained in:
Levi Siuzdak (sile)
2024-02-29 14:07:45 +00:00
parent 1c9e1f51a8
commit bdd2013fc9
@@ -8,6 +8,7 @@ import { deserializeDateTime } from "@web/core/l10n/dates";
import { registry } from "@web/core/registry";
import { useService } from "@web/core/utils/hooks";
import { useDebounced } from "@web/core/utils/timing";
import { isIosApp } from "@web/core/browser/feature_detection";
const { DateTime } = luxon;
export class ActivityMenu extends Component {
@@ -52,7 +53,8 @@ export class ActivityMenu extends Component {
}
async signInOut() {
if(navigator.geolocation){
// iOS app lacks permissions to call `getCurrentPosition`
if (!isIosApp()) {
navigator.geolocation.getCurrentPosition(
async ({coords: {latitude, longitude}}) => {
await this.rpc("/hr_attendance/systray_check_in_out", {
@@ -66,8 +68,7 @@ export class ActivityMenu extends Component {
await this.searchReadEmployee()
}
)
}
else{
} else {
await this.rpc("/hr_attendance/systray_check_in_out")
await this.searchReadEmployee()
}