diff --git a/src/components/navbar/MangaUpdatesUpdater.vue b/src/components/navbar/MangaUpdatesUpdater.vue index dc7a6b6..e797d08 100644 --- a/src/components/navbar/MangaUpdatesUpdater.vue +++ b/src/components/navbar/MangaUpdatesUpdater.vue @@ -3,6 +3,7 @@ import {Progress} from '@/data/service/MangaUpdatesDataService'; import {Options, Vue} from 'vue-class-component'; import {ServiceStore} from '@/stores/ServiceStore'; import {BSpinner} from 'bootstrap-vue-next'; +import {toast} from 'vue3-toastify'; @Options({ name: 'MangaUpdatesUpdater', @@ -35,10 +36,7 @@ export default class MangaUpdatesUpdater extends Vue { //event handler async onUpdateMangaUpdatesDb(): Promise { this.progressType = 'starting'; - try { - this.wakeLock = await navigator.wakeLock.request(); - } catch (_) { - } + await this.tryAcquireWakeLock(); this.serviceStore.mangaUpdatesDataService.updateDb(this.progress); }; @@ -67,6 +65,19 @@ export default class MangaUpdatesUpdater extends Vue { this.progressValue = null; this.progressMax = null; } + + //functions + private async tryAcquireWakeLock(): Promise { + try { + if (navigator.wakeLock) { + this.wakeLock = await navigator.wakeLock.request('screen'); + } else { + toast.warning(this.$t('wakeLock.permissionDenied')); + } + } catch (err: any) { + toast.warning(this.$t('wakelock.notSupported')); + } + } } diff --git a/src/locale/de.ts b/src/locale/de.ts index 347c188..749c492 100644 --- a/src/locale/de.ts +++ b/src/locale/de.ts @@ -39,6 +39,10 @@ export const messagesDe = { title: 'Titel', }, search: 'Suche', + wakeLock: { + notSupported: 'Wake lock wird nicht unterstützt! Das Gerät könnte Sync-Funktion unterbrechen.', + permissionDenied: 'Wake lock ist nicht erlaubt! Das Gerät könnte Sync-Funktion unterbrechen.', + }, }; export const datetimeFormatsDe = { diff --git a/src/locale/en.ts b/src/locale/en.ts index cb36121..637ecdc 100644 --- a/src/locale/en.ts +++ b/src/locale/en.ts @@ -40,6 +40,10 @@ export const messagesEn = { title: 'Title', }, search: 'Search', + wakeLock: { + notSupported: 'Wake lock is not supported! The device could pause the sync function.', + permissionDenied: 'Wake lock is not allowed! The device could pause the sync function.', + }, }; export const datetimeFormatsEn = {