mirror of
https://github.com/edu4rdshl/gnome-shell.git
synced 2026-07-18 07:34:54 +00:00
fixup! breakManager: Add new state machine for screen time/health breaks
This commit is contained in:
parent
80719358e5
commit
d4e57d3e20
1 changed files with 13 additions and 9 deletions
|
|
@ -740,19 +740,23 @@ class BreakDispatcher extends GObject.Object {
|
|||
const [nextBreakType, nextBreakDueTime] = this._manager.getNextBreakDue(currentTime);
|
||||
|
||||
if (this._manager.breakTypeShouldCountdown(nextBreakType)) {
|
||||
const countdownStart = Math.max((nextBreakDueTime - currentTime) - BREAK_COUNTDOWN_TIME_SECONDS, 0);
|
||||
const dueInSeconds = nextBreakDueTime - currentTime;
|
||||
const countdownStart = Math.max(dueInSeconds - BREAK_COUNTDOWN_TIME_SECONDS, 0);
|
||||
console.debug(`BreakDispatcher: Scheduling break countdown to start in ${countdownStart}s`);
|
||||
|
||||
if (this._countdownTimerId !== 0)
|
||||
GLib.source_remove(this._countdownTimerId);
|
||||
this._countdownTimerId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, countdownStart, () => {
|
||||
if (this._countdownOsd == null) {
|
||||
this._countdownOsd = new OsdBreakCountdownLabel(this._manager);
|
||||
this._countdownOsd.connect('destroy', () => (this._countdownOsd = null));
|
||||
}
|
||||
this._countdownTimerId = 0;
|
||||
return GLib.SOURCE_REMOVE;
|
||||
});
|
||||
this._countdownTimerId = GLib.timeout_add_seconds(
|
||||
GLib.PRIORITY_DEFAULT,
|
||||
countdownStart, () => {
|
||||
if (this._countdownOsd == null) {
|
||||
this._countdownOsd = new OsdBreakCountdownLabel(this._manager);
|
||||
this._countdownOsd.connect('destroy',
|
||||
() => (this._countdownOsd = null));
|
||||
}
|
||||
this._countdownTimerId = 0;
|
||||
return GLib.SOURCE_REMOVE;
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue