🐛 Fix dark mode toggle after navigation

This commit is contained in:
itskovacs 2025-08-28 20:26:02 +02:00
parent 1a4a635366
commit dc156263b2
2 changed files with 10 additions and 5 deletions

View File

@ -80,7 +80,7 @@ export interface MarkerOptions extends L.MarkerOptions {
styleUrls: ["./dashboard.component.scss"], styleUrls: ["./dashboard.component.scss"],
}) })
export class DashboardComponent implements OnInit, AfterViewInit { export class DashboardComponent implements OnInit, AfterViewInit {
searchInput = new FormControl("", { nonNullable: true }); searchInput = new FormControl("");
info?: Info; info?: Info;
isLowNet = false; isLowNet = false;
isDarkMode = false; isDarkMode = false;
@ -181,7 +181,7 @@ export class DashboardComponent implements OnInit, AfterViewInit {
this.isLowNet = !!settings.mode_low_network; this.isLowNet = !!settings.mode_low_network;
this.isDarkMode = !!settings.mode_dark; this.isDarkMode = !!settings.mode_dark;
this.isGpxInPlaceMode = !!settings.mode_gpx_in_place; this.isGpxInPlaceMode = !!settings.mode_gpx_in_place;
if (this.isDarkMode) this.utilsService.toggleDarkMode(); if (this.isDarkMode) this.utilsService.enableDarkMode();
this.resetFilters(); this.resetFilters();
this.places = [...places]; this.places = [...places];
@ -260,12 +260,12 @@ export class DashboardComponent implements OnInit, AfterViewInit {
this.markerClusterGroup?.clearLayers(); this.markerClusterGroup?.clearLayers();
this.filteredPlaces.forEach((place) => { this.filteredPlaces.forEach((place) => {
const marker = this.placeToMarker(place); const marker = this._placeToMarker(place);
this.markerClusterGroup?.addLayer(marker); this.markerClusterGroup?.addLayer(marker);
}); });
} }
placeToMarker(place: Place): L.Marker { _placeToMarker(place: Place): L.Marker {
const marker = placeToMarker( const marker = placeToMarker(
place, place,
this.isLowNet, this.isLowNet,
@ -634,7 +634,7 @@ export class DashboardComponent implements OnInit, AfterViewInit {
this.isLowNet = !!resp.settings.mode_low_network; this.isLowNet = !!resp.settings.mode_low_network;
this.isDarkMode = !!resp.settings.mode_dark; this.isDarkMode = !!resp.settings.mode_dark;
this.isGpxInPlaceMode = !!resp.settings.mode_gpx_in_place; this.isGpxInPlaceMode = !!resp.settings.mode_gpx_in_place;
if (this.isDarkMode) this.utilsService.toggleDarkMode(); if (this.isDarkMode) this.utilsService.enableDarkMode();
this.resetFilters(); this.resetFilters();
this.map?.remove(); this.map?.remove();

View File

@ -31,6 +31,11 @@ export class UtilsService {
element?.classList.toggle("dark"); element?.classList.toggle("dark");
} }
enableDarkMode() {
const element = document.querySelector("html");
element?.classList.toggle("dark", true);
}
toast( toast(
severity: ToastSeverity = "info", severity: ToastSeverity = "info",
summary = "Info", summary = "Info",