Sort video categories/languages

pull/304/head
Chocobozzz 2018-02-20 09:50:44 +01:00
parent 6ff9c676e9
commit 3580fc00e4
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 12 additions and 3 deletions

View File

@ -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<boolean>
notifier: ReplaySubject<boolean>,
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)
})
}