From 4cea72ddc74e18356d323b4cf1dc37767c5d6baf Mon Sep 17 00:00:00 2001 From: itskovacs Date: Thu, 7 Aug 2025 18:48:07 +0200 Subject: [PATCH] :lipstick: Sort displayed categories by name --- .../app/components/dashboard/dashboard.component.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/src/app/components/dashboard/dashboard.component.ts b/src/src/app/components/dashboard/dashboard.component.ts index ef1b8c5..02d88c7 100644 --- a/src/src/app/components/dashboard/dashboard.component.ts +++ b/src/src/app/components/dashboard/dashboard.component.ts @@ -175,6 +175,7 @@ export class DashboardComponent implements OnInit, AfterViewInit { this.initMap(); this.categories = categories; + this.sortCategories(); this.activeCategories = new Set(categories.map((c) => c.name)); this.isLowNet = !!settings.mode_low_network; @@ -623,6 +624,7 @@ export class DashboardComponent implements OnInit, AfterViewInit { ); this.categories = resp.categories; + this.sortCategories(); this.activeCategories = new Set(resp.categories.map((c) => c.name)); this.settings = resp.settings; @@ -707,6 +709,7 @@ export class DashboardComponent implements OnInit, AfterViewInit { this.categories = this.categories.map((cat) => cat.id === updated.id ? updated : cat, ); + this.sortCategories(); this.activeCategories = new Set( this.categories.map((c) => c.name), @@ -797,6 +800,13 @@ export class DashboardComponent implements OnInit, AfterViewInit { this.map?.flyTo([p.lat, p.lng]); } + sortCategories() { + this.categories = [...this.categories].sort( + (categoryA: Category, categoryB: Category) => + categoryA.name.localeCompare(categoryB.name), + ); + } + gotoTrips() { this.router.navigateByUrl("/trips"); }