From 3580fc00e44db980c371cbf16b4806f4240945f2 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 20 Feb 2018 09:50:44 +0100 Subject: Sort video categories/languages --- client/src/app/core/server/server.service.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts index 553ad8af6..f54e63efd 100644 --- a/client/src/app/core/server/server.service.ts +++ b/client/src/app/core/server/server.service.ts @@ -60,7 +60,7 @@ export class ServerService { } loadVideoCategories () { - return this.loadVideoAttributeEnum('categories', this.videoCategories, this.videoCategoriesLoaded) + return this.loadVideoAttributeEnum('categories', this.videoCategories, this.videoCategoriesLoaded, true) } loadVideoLicences () { @@ -68,7 +68,7 @@ export class ServerService { } loadVideoLanguages () { - return this.loadVideoAttributeEnum('languages', this.videoLanguages, this.videoLanguagesLoaded) + return this.loadVideoAttributeEnum('languages', this.videoLanguages, this.videoLanguagesLoaded, true) } loadVideoPrivacies () { @@ -102,7 +102,8 @@ export class ServerService { private loadVideoAttributeEnum ( attributeName: 'categories' | 'licences' | 'languages' | 'privacies', hashToPopulate: { id: number, label: string }[], - notifier: ReplaySubject + notifier: ReplaySubject, + sort = false ) { return this.http.get(ServerService.BASE_VIDEO_URL + attributeName) .subscribe(data => { @@ -114,6 +115,14 @@ export class ServerService { }) }) + if (sort === true) { + hashToPopulate.sort((a, b) => { + if (a.label < b.label) return -1 + if (a.label === b.label) return 0 + return 1 + }) + } + notifier.next(true) }) } -- cgit v1.2.3