From 5bf6d634f453c9db7b7fdc512d9fb2013a9c17bc Mon Sep 17 00:00:00 2001 From: Dominik Kus Date: Mon, 6 Nov 2023 20:05:57 +0100 Subject: [PATCH] sort sounds by name in dashboard and settings (closes #14) sounds are sorted by their name in ascending order case-insensitively --- frontend/src/app/services/sounds.service.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/services/sounds.service.ts b/frontend/src/app/services/sounds.service.ts index 6bb1283..311ac3a 100644 --- a/frontend/src/app/services/sounds.service.ts +++ b/frontend/src/app/services/sounds.service.ts @@ -1,6 +1,7 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { map } from 'rxjs/operators'; +import { sortBy } from 'lodash-es'; import { Guild } from './api.service'; interface ApiSound { @@ -64,7 +65,10 @@ export class SoundsService { constructor(private http: HttpClient) {} loadSounds() { - return this.http.get('/api/sounds').pipe(map(sounds => sounds.map(sound => new Sound(sound)))); + return this.http.get('/api/sounds').pipe( + map(sounds => sounds.map(sound => new Sound(sound))), + map(sounds => sortBy(sounds, sound => sound.name.toLowerCase())) + ); } playSound(sound: Sound, guild: Guild | string, autojoin: boolean) {