Night Light Timer: Reduce D-Bus calls
This commit is contained in:
@@ -34,7 +34,7 @@ var TimerNightlight = class {
|
|||||||
#colorDbusProxy = null;
|
#colorDbusProxy = null;
|
||||||
#settingsConnections = [];
|
#settingsConnections = [];
|
||||||
#nightlightStateConnection = null;
|
#nightlightStateConnection = null;
|
||||||
#previousNightlightActive = null;
|
#previousNightlightState = null;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.#settings = extensionUtils.getSettings(utils.getSettingsSchema('time'));
|
this.#settings = extensionUtils.getSettings(utils.getSettingsSchema('time'));
|
||||||
@@ -124,10 +124,11 @@ var TimerNightlight = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#onNightlightStateChanged(_sender, _dbusProperties) {
|
#onNightlightStateChanged(_sender, _dbusProperties) {
|
||||||
if (this.#isNightlightActive() !== this.#previousNightlightActive) {
|
const newState = this.#isNightlightActive();
|
||||||
console.debug(`Night Light has become ${this.#isNightlightActive() ? '' : 'in'}active.`);
|
if (newState !== this.#previousNightlightState) {
|
||||||
this.#previousNightlightActive = this.#isNightlightActive();
|
console.debug(`Night Light has become ${newState ? '' : 'in'}active.`);
|
||||||
this.emit('time-changed', this.time);
|
this.#previousNightlightState = newState;
|
||||||
|
this.emit('time-changed', newState ? Time.NIGHT : Time.DAY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user