timeLimitsManager: Only stop the state machine if it’s already running
This fixes a bug which happens if screen time limits are *disabled* and the history file (`~/.local/share/gnome-shell/session-active-history.json`) is missing when gnome-shell is started. If so, the code would previously have incorrectly called `this._stopStateMachine()` on startup, even though the state machine wasn’t running. This adds a fake transition from ACTIVE to INACTIVE to the history file. If the user later (that day) enables time limits, the code assumes that they were active from the start of the day through to that fake transition, which is possibly sufficient time to reach the user’s limit already. This results in the screen immediately being made greyscale as the limit has apparently been reached. Signed-off-by: Philip Withnall <pwithnall@gnome.org> Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/8155 Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3597>
This commit is contained in:
parent
b6e1eeb315
commit
08b06acc4c
@ -169,8 +169,10 @@ export const TimeLimitsManager = GObject.registerClass({
|
||||
|
||||
_updateSettings() {
|
||||
if (!this._screenTimeLimitSettings.get_boolean('enabled')) {
|
||||
this._stopStateMachine().catch(
|
||||
e => console.warn(`Failed to stop state machine: ${e.message}`));
|
||||
if (this._state !== TimeLimitsState.DISABLED) {
|
||||
this._stopStateMachine().catch(
|
||||
e => console.warn(`Failed to stop state machine: ${e.message}`));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user