Use NoSleep to prevent sleep of the phone

This commit is contained in:
Lucas Verney 2018-06-25 23:57:33 +02:00
parent d59d84af43
commit dd4075b18c
3 changed files with 20 additions and 0 deletions

View File

@ -16,6 +16,7 @@
"leaflet": "^1.3.1",
"leaflet-tracksymbol": "^1.0.8",
"material-icons": "^0.2.3",
"nosleep.js": "^0.7.0",
"roboto-fontface": "^0.9.0",
"vue": "^2.5.2",
"vue-i18n": "^7.8.1",

View File

@ -28,6 +28,8 @@
</template>
<script>
import NoSleep from 'nosleep.js';
import { MOCK_LOCATION } from '@/constants';
import Map from '@/components/Map.vue';
import ReportDialog from '@/components/ReportDialog/index.vue';
@ -39,8 +41,10 @@ export default {
},
created() {
this.initializePositionWatching();
this.setNoSleep();
},
beforeDestroy() {
this.disableNoSleep();
this.disablePositionWatching();
},
data() {
@ -50,6 +54,7 @@ export default {
heading: null,
lat: null,
lng: null,
noSleep: null,
watchID: null,
};
},
@ -94,6 +99,16 @@ export default {
this.heading = null;
}
},
setNoSleep() {
this.noSleep = new NoSleep();
console.log(this.noSleep);
this.noSleep.enable();
},
disableNoSleep() {
if (this.noSleep) {
this.noSleep.disable();
}
},
},
};
</script>

View File

@ -4005,6 +4005,10 @@ normalize-url@^1.4.0:
query-string "^4.1.0"
sort-keys "^1.0.0"
nosleep.js@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/nosleep.js/-/nosleep.js-0.7.0.tgz#cfd919c25523ca0d0f4a69fb3305c083adaee289"
npm-bundled@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.0.3.tgz#7e71703d973af3370a9591bafe3a63aca0be2308"