Night Light Timer: Reduce D-Bus calls

This commit is contained in:
Romain Vigier
2022-08-16 01:26:00 +02:00
parent 0a18075787
commit 3a0d9036d3
+6 -5
View File
@@ -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);
} }
} }