From 4511af2fdc61881f3bd716ccd8008ac5ffc6a6e6 Mon Sep 17 00:00:00 2001 From: JasonReed-2 Date: Sat, 14 Oct 2023 22:20:50 -0500 Subject: [PATCH 1/3] Client side of idle tracking --- .../components/battle/BattleComponent.vue | 11 +++++++ src/renderer/utils/idle-timer.ts | 33 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 src/renderer/utils/idle-timer.ts diff --git a/src/renderer/components/battle/BattleComponent.vue b/src/renderer/components/battle/BattleComponent.vue index 22eb9404..14c928d3 100644 --- a/src/renderer/components/battle/BattleComponent.vue +++ b/src/renderer/components/battle/BattleComponent.vue @@ -215,6 +215,7 @@ import { AbstractBattle } from "@/model/battle/abstract-battle"; import { StartPosType } from "@/model/battle/battle-types"; import { LuaOptionSection } from "@/model/lua-options"; import { CurrentUser } from "@/model/user"; +import { setIdleTimer } from "@/utils/idle-timer"; import { StartBoxOrientation } from "@/utils/start-boxes"; import { isOfflineBattle, isSpadsBattle } from "@/utils/type-checkers"; @@ -237,6 +238,8 @@ const gameOptionsOpen = ref(false); const gameOptions: Ref = ref([]); const isGameRunning = api.game.isGameRunning; +setIdleTimer(onIdle, onBack, 5); + function openMapList() { mapListOpen.value = true; } @@ -335,6 +338,14 @@ function leave() { async function start() { props.battle.start(); } + +function onIdle() { + console.log("Is Away!"); +} + +function onBack() { + console.log("Is Back!"); +}