modular
This commit is contained in:
parent
b71d696670
commit
6933e7b7f1
26 changed files with 600 additions and 873 deletions
18
server/scripts/modules/utils/nosleep.mjs
Normal file
18
server/scripts/modules/utils/nosleep.mjs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// track state of nosleep locally to avoid a null case error
|
||||
// when nosleep.disable is called without first calling .enable
|
||||
|
||||
let wakeLock = false;
|
||||
|
||||
const noSleep = (enable = false) => {
|
||||
// get a nosleep controller
|
||||
if (!noSleep.controller) noSleep.controller = new NoSleep();
|
||||
// don't call anything if the states match
|
||||
if (wakeLock === enable) return false;
|
||||
// store the value
|
||||
wakeLock = enable;
|
||||
// call the function
|
||||
if (enable) return noSleep.controller.enable();
|
||||
return noSleep.controller.disable();
|
||||
};
|
||||
|
||||
export default noSleep;
|
||||
Loading…
Add table
Add a link
Reference in a new issue