aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-02-20 09:50:44 +0100
committerChocobozzz <me@florianbigard.com>2018-02-20 09:50:44 +0100
commit3580fc00e44db980c371cbf16b4806f4240945f2 (patch)
tree7786d2bc00be91692f335f5a39fbc691e62867e9
parent6ff9c676e9a7be29a21734f74b66300bde47b1c9 (diff)
downloadPeerTube-3580fc00e44db980c371cbf16b4806f4240945f2.tar.gz
PeerTube-3580fc00e44db980c371cbf16b4806f4240945f2.tar.zst
PeerTube-3580fc00e44db980c371cbf16b4806f4240945f2.zip
Sort video categories/languages
-rw-r--r--client/src/app/core/server/server.service.ts15
1 files 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 {
60 } 60 }
61 61
62 loadVideoCategories () { 62 loadVideoCategories () {
63 return this.loadVideoAttributeEnum('categories', this.videoCategories, this.videoCategoriesLoaded) 63 return this.loadVideoAttributeEnum('categories', this.videoCategories, this.videoCategoriesLoaded, true)
64 } 64 }
65 65
66 loadVideoLicences () { 66 loadVideoLicences () {
@@ -68,7 +68,7 @@ export class ServerService {
68 } 68 }
69 69
70 loadVideoLanguages () { 70 loadVideoLanguages () {
71 return this.loadVideoAttributeEnum('languages', this.videoLanguages, this.videoLanguagesLoaded) 71 return this.loadVideoAttributeEnum('languages', this.videoLanguages, this.videoLanguagesLoaded, true)
72 } 72 }
73 73
74 loadVideoPrivacies () { 74 loadVideoPrivacies () {
@@ -102,7 +102,8 @@ export class ServerService {
102 private loadVideoAttributeEnum ( 102 private loadVideoAttributeEnum (
103 attributeName: 'categories' | 'licences' | 'languages' | 'privacies', 103 attributeName: 'categories' | 'licences' | 'languages' | 'privacies',
104 hashToPopulate: { id: number, label: string }[], 104 hashToPopulate: { id: number, label: string }[],
105 notifier: ReplaySubject<boolean> 105 notifier: ReplaySubject<boolean>,
106 sort = false
106 ) { 107 ) {
107 return this.http.get(ServerService.BASE_VIDEO_URL + attributeName) 108 return this.http.get(ServerService.BASE_VIDEO_URL + attributeName)
108 .subscribe(data => { 109 .subscribe(data => {
@@ -114,6 +115,14 @@ export class ServerService {
114 }) 115 })
115 }) 116 })
116 117
118 if (sort === true) {
119 hashToPopulate.sort((a, b) => {
120 if (a.label < b.label) return -1
121 if (a.label === b.label) return 0
122 return 1
123 })
124 }
125
117 notifier.next(true) 126 notifier.next(true)
118 }) 127 })
119 } 128 }