Skip to content

Commit 87beff9

Browse files
committed
again try fix throttling when period end
1 parent b473c6f commit 87beff9

2 files changed

Lines changed: 51 additions & 2 deletions

File tree

main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ function createWindow() {
6868
webgl: false,
6969
contextIsolation: false,
7070
enableRemoteModule: true,
71-
spellcheck: false
71+
spellcheck: false,
72+
backgroundThrottling: false
7273
},
7374
titleBarStyle: "hiddenInset",
7475
icon: "./res/icons/wnrIcon.png"

timer.html

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,29 @@ <h3>
378378
call("floating");
379379
hasFloating = true;
380380

381-
//repeat so always able to be sent
381+
// Send immediate heartbeat first to prevent freeze at zero
382+
if (methodFromStart !== 3) {
383+
let remainingMs = ((method === 1) ? workTime : restTime) - new Date().getTime() + startTime -
384+
(times === 0 ? firstTimeDiscount : 0);
385+
if (remainingMs < 0) remainingMs = 0;
386+
ipc.send("floating-heartbeat", {
387+
remainingSeconds: Math.floor(remainingMs / 1000),
388+
totalMs: (method === 1) ? workTime : restTime,
389+
method: method,
390+
isWorking: isClockWorking,
391+
isOnlyRest: isOnlyRest
392+
});
393+
} else {
394+
ipc.send("floating-heartbeat", {
395+
remainingSeconds: seconds,
396+
totalMs: 0,
397+
method: 3,
398+
isWorking: isClockWorking,
399+
isOnlyRest: isOnlyRest
400+
});
401+
}
402+
403+
// Repeat so always able to be sent (backup heartbeats)
382404
if (methodFromStart !== 3)
383405
for (let floatingRepeater = 1; floatingRepeater < 5; floatingRepeater++)
384406
setTimeout(function () {
@@ -1247,6 +1269,19 @@ <h3>
12471269
$("#skipper-container").css("display", "inline");
12481270
}
12491271
}
1272+
// Send immediate heartbeat after state change to prevent freeze at zero
1273+
if (hasFloating && times !== loop * 2) {
1274+
let remainingMs = ((method === 1) ? workTime : restTime) - new Date().getTime() + startTime -
1275+
(times === 0 ? firstTimeDiscount : 0);
1276+
if (remainingMs < 0) remainingMs = 0;
1277+
ipc.send("floating-heartbeat", {
1278+
remainingSeconds: Math.floor(remainingMs / 1000),
1279+
totalMs: (method === 1) ? workTime : restTime,
1280+
method: methodFromStart === 3 ? 3 : method,
1281+
isWorking: isClockWorking,
1282+
isOnlyRest: isOnlyRest
1283+
});
1284+
}
12501285
} else {
12511286
stopper();
12521287
setTimeout(function () {
@@ -1273,6 +1308,19 @@ <h3>
12731308
$("#skipper-container").css("display", "inline");
12741309
}
12751310
}
1311+
// Send immediate heartbeat after state change to prevent freeze at zero
1312+
if (hasFloating && times !== loop * 2) {
1313+
let remainingMs = ((method === 1) ? workTime : restTime) - new Date().getTime() + startTime -
1314+
(times === 0 ? firstTimeDiscount : 0);
1315+
if (remainingMs < 0) remainingMs = 0;
1316+
ipc.send("floating-heartbeat", {
1317+
remainingSeconds: Math.floor(remainingMs / 1000),
1318+
totalMs: (method === 1) ? workTime : restTime,
1319+
method: methodFromStart === 3 ? 3 : method,
1320+
isWorking: isClockWorking,
1321+
isOnlyRest: isOnlyRest
1322+
});
1323+
}
12761324
}, 250);
12771325
}
12781326
}

0 commit comments

Comments
 (0)