💄 Sort displayed categories by name

This commit is contained in:
itskovacs 2025-08-07 18:48:07 +02:00
parent ae5a6840a7
commit 4cea72ddc7

View File

@ -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");
}