MOBILE-2159 geolocation: Replace type guard with simpler code
parent
74362d2aba
commit
3d67ee62de
|
@ -117,7 +117,7 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginCo
|
||||||
this.form.controls['f_' + this.field.id + '_0'].setValue(result.coords.latitude);
|
this.form.controls['f_' + this.field.id + '_0'].setValue(result.coords.latitude);
|
||||||
this.form.controls['f_' + this.field.id + '_1'].setValue(result.coords.longitude);
|
this.form.controls['f_' + this.field.id + '_1'].setValue(result.coords.longitude);
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
if (this.isPositionError(error) && error.code === error.PERMISSION_DENIED) {
|
if (this.isPermissionDeniedError(error)) {
|
||||||
this.domUtils.showErrorModal('addon.mod_data.locationpermissiondenied', true);
|
this.domUtils.showErrorModal('addon.mod_data.locationpermissiondenied', true);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -129,7 +129,7 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginCo
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected isPositionError(error?: any): error is PositionError {
|
protected isPermissionDeniedError(error?: any): boolean {
|
||||||
return error && 'code' in error && 'PERMISSION_DENIED' in error;
|
return error && 'code' in error && 'PERMISSION_DENIED' in error && error.code === error.PERMISSION_DENIED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue