MOBILE-2159 geolocation: Replace type guard with simpler code

main
Noel De Martin 2019-12-11 10:18:21 +01:00
parent 74362d2aba
commit 3d67ee62de
1 changed files with 3 additions and 3 deletions

View File

@ -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 + '_1'].setValue(result.coords.longitude);
}).catch((error) => {
if (this.isPositionError(error) && error.code === error.PERMISSION_DENIED) {
if (this.isPermissionDeniedError(error)) {
this.domUtils.showErrorModal('addon.mod_data.locationpermissiondenied', true);
return;
@ -129,7 +129,7 @@ export class AddonModDataFieldLatlongComponent extends AddonModDataFieldPluginCo
});
}
protected isPositionError(error?: any): error is PositionError {
return error && 'code' in error && 'PERMISSION_DENIED' in error;
protected isPermissionDeniedError(error?: any): boolean {
return error && 'code' in error && 'PERMISSION_DENIED' in error && error.code === error.PERMISSION_DENIED;
}
}