1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00
joplin/ReactNativeClient/lib/geolocation-react.js
Laurent Cozic a96734f5be Revert "Tools: Added eslint rule arrow-parens"
This reverts commit 0b6f5581f0.

It causes too many conflicts with pull requests.
2020-05-21 09:14:33 +01:00

41 lines
873 B
JavaScript

const Setting = require('lib/models/Setting.js');
class GeolocationReact {
static currentPosition_testResponse() {
return {
mocked: false,
timestamp: new Date().getTime(),
coords: {
speed: 0,
heading: 0,
accuracy: 20,
longitude: -3.4596633911132812,
altitude: 0,
latitude: 48.73219093634444,
},
};
}
static currentPosition(options = null) {
if (Setting.value('env') == 'dev') return this.currentPosition_testResponse();
if (!options) options = {};
if (!('enableHighAccuracy' in options)) options.enableHighAccuracy = true;
if (!('timeout' in options)) options.timeout = 10000;
return new Promise((resolve, reject) => {
navigator.geolocation.getCurrentPosition(
data => {
resolve(data);
},
error => {
reject(error);
},
options
);
});
}
}
module.exports = { GeolocationReact };