From acdd8f6964b92275ae63b8f32bb59520ba10c923 Mon Sep 17 00:00:00 2001 From: youhavetrouble Date: Mon, 26 Jun 2023 16:03:39 +0200 Subject: [PATCH] prevent phones from turning off display when the game's running --- src/App.vue | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/App.vue b/src/App.vue index 17b2bd9..fbe9dbc 100644 --- a/src/App.vue +++ b/src/App.vue @@ -80,6 +80,7 @@ export default defineComponent({ name: "GuildView", data: () => ({ loading: true as boolean, + screenWakeLock: null as null | WakeLockSentinel, guild: new Guild(1, 500), gameTickTask: null as null | number, gameSaveTask: null as null | number, @@ -266,6 +267,15 @@ export default defineComponent({ } }, async mounted() { + + setInterval(async () => { + if (this.screenWakeLock) return; + try { + this.screenWakeLock = await navigator.wakeLock.request("screen"); + console.debug("Screen wake lock acquired"); + } catch (e) {} + }, 1000); + console.debug("Loading game data") const promises = await Promise.all([ loadAvailableQuests(),