Skip to content

Commit

Permalink
Remove timeout for NoSleep
Browse files Browse the repository at this point in the history
  • Loading branch information
schlagmichdoch committed Feb 9, 2024
1 parent ef816f9 commit 4248e03
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions public/scripts/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2955,25 +2955,18 @@ class WebFileHandlersUI {
class NoSleepUI {
constructor() {
NoSleepUI._nosleep = new NoSleep();
NoSleepUI._active = false;
}

static enable() {
if (NoSleepUI._interval) return;
if (NoSleepUI._active) return;

NoSleepUI._nosleep = new NoSleep();
NoSleepUI._nosleep.enable();

// Disable after 20s if all peers are idle
NoSleepUI._interval = setInterval(() => NoSleepUI.disableIfPeersIdle(), 20000);
NoSleepUI._active = true;
}

static disableIfPeersIdle() {
//peers are still transferring -> abort
if ($$('x-peer[status]')) return;

clearInterval(NoSleepUI._interval);
NoSleepUI._interval = null;

NoSleepUI._nosleep.disable();
NoSleepUI._active = false;
}
}

0 comments on commit 4248e03

Please sign in to comment.