added wake lock to MangaUpdatesUpdater.vue to prevent phones going into sleep mode while fetching updates (updates won't be fetched if phone goes to sleep)
This commit is contained in:
@@ -17,13 +17,19 @@ export default class MangaUpdatesUpdater extends Vue {
|
|||||||
progressValue: number | null = null;
|
progressValue: number | null = null;
|
||||||
progressMax: number | null = null;
|
progressMax: number | null = null;
|
||||||
|
|
||||||
|
wakeLock: WakeLockSentinel | null = null;
|
||||||
|
|
||||||
get serviceStore(): ServiceStore {
|
get serviceStore(): ServiceStore {
|
||||||
return new ServiceStore();
|
return new ServiceStore();
|
||||||
}
|
}
|
||||||
|
|
||||||
//event handler
|
//event handler
|
||||||
onUpdateMangaUpdatesDb(): void {
|
async onUpdateMangaUpdatesDb(): Promise<void> {
|
||||||
this.progressType = 'starting';
|
this.progressType = 'starting';
|
||||||
|
try {
|
||||||
|
this.wakeLock = await navigator.wakeLock.request();
|
||||||
|
} catch (_) {
|
||||||
|
}
|
||||||
this.serviceStore.mangaUpdatesDataService.updateDb(this.progress);
|
this.serviceStore.mangaUpdatesDataService.updateDb(this.progress);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -35,13 +41,20 @@ export default class MangaUpdatesUpdater extends Vue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onFinished(): void {
|
onFinished(): void {
|
||||||
|
this.wakeLock?.release();
|
||||||
|
this.wakeLock = null;
|
||||||
|
|
||||||
this.progressType = 'finished';
|
this.progressType = 'finished';
|
||||||
this.progressValue = null;
|
this.progressValue = null;
|
||||||
this.progressMax = null;
|
this.progressMax = null;
|
||||||
|
|
||||||
setTimeout(() => this.onReset(), 3000);
|
setTimeout(() => this.onReset(), 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
onReset(): void {
|
onReset(): void {
|
||||||
|
this.wakeLock?.release();
|
||||||
|
this.wakeLock = null;
|
||||||
|
|
||||||
this.progressType = null;
|
this.progressType = null;
|
||||||
this.progressValue = null;
|
this.progressValue = null;
|
||||||
this.progressMax = null;
|
this.progressMax = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user