clear intervals on disconnect

This commit is contained in:
liamcottle
2025-02-16 17:56:57 +13:00
parent 38e3375815
commit dbb0c8ec80
2 changed files with 6 additions and 1 deletions

View File

@@ -77,6 +77,10 @@ class Connection {
// update ui
GlobalState.connection = null;
// clear previous connection timers
clearInterval(GlobalState.batteryPercentageInterval);
GlobalState.batteryPercentageInterval = null;
}
static async onConnected() {
@@ -155,7 +159,7 @@ class Connection {
await this.updateBatteryPercentage();
// auto update battery percentage once per minute
setInterval(async () => {
GlobalState.batteryPercentageInterval = setInterval(async () => {
await this.updateBatteryPercentage();
}, 60000);

View File

@@ -6,6 +6,7 @@ const globalState = reactive({
isDatabaseReady: false,
selfInfo: null,
batteryPercentage: null,
batteryPercentageInterval: null,
contacts: [],
channels: [
{