From dc156263b2605f9351d576ebb2ea7550518fb316 Mon Sep 17 00:00:00 2001 From: itskovacs Date: Thu, 28 Aug 2025 20:26:02 +0200 Subject: [PATCH] :bug: Fix dark mode toggle after navigation --- .../app/components/dashboard/dashboard.component.ts | 10 +++++----- src/src/app/services/utils.service.ts | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/src/app/components/dashboard/dashboard.component.ts b/src/src/app/components/dashboard/dashboard.component.ts index 1718c35..2067b8b 100644 --- a/src/src/app/components/dashboard/dashboard.component.ts +++ b/src/src/app/components/dashboard/dashboard.component.ts @@ -80,7 +80,7 @@ export interface MarkerOptions extends L.MarkerOptions { styleUrls: ["./dashboard.component.scss"], }) export class DashboardComponent implements OnInit, AfterViewInit { - searchInput = new FormControl("", { nonNullable: true }); + searchInput = new FormControl(""); info?: Info; isLowNet = false; isDarkMode = false; @@ -181,7 +181,7 @@ export class DashboardComponent implements OnInit, AfterViewInit { this.isLowNet = !!settings.mode_low_network; this.isDarkMode = !!settings.mode_dark; this.isGpxInPlaceMode = !!settings.mode_gpx_in_place; - if (this.isDarkMode) this.utilsService.toggleDarkMode(); + if (this.isDarkMode) this.utilsService.enableDarkMode(); this.resetFilters(); this.places = [...places]; @@ -260,12 +260,12 @@ export class DashboardComponent implements OnInit, AfterViewInit { this.markerClusterGroup?.clearLayers(); this.filteredPlaces.forEach((place) => { - const marker = this.placeToMarker(place); + const marker = this._placeToMarker(place); this.markerClusterGroup?.addLayer(marker); }); } - placeToMarker(place: Place): L.Marker { + _placeToMarker(place: Place): L.Marker { const marker = placeToMarker( place, this.isLowNet, @@ -634,7 +634,7 @@ export class DashboardComponent implements OnInit, AfterViewInit { this.isLowNet = !!resp.settings.mode_low_network; this.isDarkMode = !!resp.settings.mode_dark; this.isGpxInPlaceMode = !!resp.settings.mode_gpx_in_place; - if (this.isDarkMode) this.utilsService.toggleDarkMode(); + if (this.isDarkMode) this.utilsService.enableDarkMode(); this.resetFilters(); this.map?.remove(); diff --git a/src/src/app/services/utils.service.ts b/src/src/app/services/utils.service.ts index 8ec6648..01c10a7 100644 --- a/src/src/app/services/utils.service.ts +++ b/src/src/app/services/utils.service.ts @@ -31,6 +31,11 @@ export class UtilsService { element?.classList.toggle("dark"); } + enableDarkMode() { + const element = document.querySelector("html"); + element?.classList.toggle("dark", true); + } + toast( severity: ToastSeverity = "info", summary = "Info",