refactor: remove geoLocation from settings

Closes #99
This commit is contained in:
Jovan Krunić
2021-04-19 16:49:45 +02:00
parent 7928534d88
commit 3da7c7d009
7 changed files with 7 additions and 110 deletions

View File

@@ -13,7 +13,6 @@
* this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Injectable} from '@angular/core';
import {Geolocation} from '@ionic-native/geolocation/ngx';
import {
SCSetting,
SCSettingValue,
@@ -196,11 +195,9 @@ export class SettingsProvider {
*
* @param storage TODO
* @param configProvider TODO
* @param geoLocation TODO
*/
constructor(private readonly storage: StorageProvider,
private readonly configProvider: ConfigProvider,
private readonly geoLocation: Geolocation) {
private readonly configProvider: ConfigProvider) {
this.categoriesOrder = [];
this.settingsCache = {};
}
@@ -265,32 +262,6 @@ export class SettingsProvider {
return this.settingsCache[category] !== undefined;
}
/**
* Checks for user permission to use location
*/
public async checkGeoLocationPermission(): Promise<boolean> {
// request geoLocation to test the user permission
try {
// set enableHighAccuracy, otherwise android platform does not respond
const options = {
enableHighAccuracy: true,
};
await this.geoLocation.getCurrentPosition(options);
} catch (error) {
// if error code is 1 the user denied permission,
// other errors like 'timeout' or 'no location' will be ignored here
if (error.code === 1) {
// ios has special error message for disabled location services, for the setting we ignore it
if (error.message.toLowerCase() !== 'location services are disabled.') {
// revert setting value
return false;
}
}
}
return true;
}
/**
* Returns copy of cached settings
*/