From 4d023d9f9fb27a109943178f11e03427ae11c702 Mon Sep 17 00:00:00 2001 From: Johnny Arcitec <14483309-Arcitec@users.noreply.gitlab.com> Date: Mon, 22 May 2023 06:45:38 +0000 Subject: [PATCH] Timer: Preserve current theme when sunrise/sunset is unavailable --- src/modules/Timer.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/modules/Timer.js b/src/modules/Timer.js index 21ac311..a72d5cb 100644 --- a/src/modules/Timer.js +++ b/src/modules/Timer.js @@ -234,6 +234,11 @@ export class Timer extends GObject.Object { } + #colorSchemeToTime() { + return this.#interfaceSettings.get_string('color-scheme') === 'prefer-dark' ? Time.NIGHT : Time.DAY; + } + + #onLocationStateChanged() { this.disable(); this.enable(); @@ -254,8 +259,7 @@ export class Timer extends GObject.Object { } #onColorSchemeChanged() { - const time = this.#interfaceSettings.get_string('color-scheme') === 'prefer-dark' ? Time.NIGHT : Time.DAY; - this.#changeTime(time, true); + this.#changeTime(this.#colorSchemeToTime(), true); } #onGeoclueReady(_geoclue, result) { @@ -319,8 +323,9 @@ export class Timer extends GObject.Object { // Sunset happens on the day after else if (sunrise > sunset) return hour >= sunrise || hour < sunset ? Time.DAY : Time.NIGHT; + // Sunset and Sunrise times are identical; preserve current theme else - return Time.DAY; + return this.#time || this.#colorSchemeToTime(); } #updateSuntimes() {