diff options
author | Chocobozzz <me@florianbigard.com> | 2018-07-25 15:11:25 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-07-25 15:11:25 +0200 |
commit | ad77475251c3516dd5851a08655be79d7bf76245 (patch) | |
tree | 3b816fa225a8b9f50bbdc6edd8bdc2d2dfbe5ce2 /client/src/app/videos | |
parent | f842e810b450a34275d8d453d5d9431a4e1b882a (diff) | |
download | PeerTube-ad77475251c3516dd5851a08655be79d7bf76245.tar.gz PeerTube-ad77475251c3516dd5851a08655be79d7bf76245.tar.zst PeerTube-ad77475251c3516dd5851a08655be79d7bf76245.zip |
Sort video captions
Diffstat (limited to 'client/src/app/videos')
-rw-r--r-- | client/src/app/videos/+video-edit/shared/video-edit.component.ts | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/client/src/app/videos/+video-edit/shared/video-edit.component.ts b/client/src/app/videos/+video-edit/shared/video-edit.component.ts index b8aef99dd..b394a13e4 100644 --- a/client/src/app/videos/+video-edit/shared/video-edit.component.ts +++ b/client/src/app/videos/+video-edit/shared/video-edit.component.ts | |||
@@ -142,12 +142,13 @@ export class VideoEditComponent implements OnInit, OnDestroy { | |||
142 | // Replace existing caption? | 142 | // Replace existing caption? |
143 | if (existingCaption) { | 143 | if (existingCaption) { |
144 | Object.assign(existingCaption, caption, { action: 'CREATE' as 'CREATE' }) | 144 | Object.assign(existingCaption, caption, { action: 'CREATE' as 'CREATE' }) |
145 | return | 145 | } else { |
146 | this.videoCaptions.push( | ||
147 | Object.assign(caption, { action: 'CREATE' as 'CREATE' }) | ||
148 | ) | ||
146 | } | 149 | } |
147 | 150 | ||
148 | this.videoCaptions.push( | 151 | this.sortVideoCaptions() |
149 | Object.assign(caption, { action: 'CREATE' as 'CREATE' }) | ||
150 | ) | ||
151 | } | 152 | } |
152 | 153 | ||
153 | async deleteCaption (caption: VideoCaptionEdit) { | 154 | async deleteCaption (caption: VideoCaptionEdit) { |
@@ -170,6 +171,15 @@ export class VideoEditComponent implements OnInit, OnDestroy { | |||
170 | this.videoCaptionAddModal.show() | 171 | this.videoCaptionAddModal.show() |
171 | } | 172 | } |
172 | 173 | ||
174 | private sortVideoCaptions () { | ||
175 | this.videoCaptions.sort((v1, v2) => { | ||
176 | if (v1.language.label < v2.language.label) return -1 | ||
177 | if (v1.language.label === v2.language.label) return 0 | ||
178 | |||
179 | return 1 | ||
180 | }) | ||
181 | } | ||
182 | |||
173 | private trackPrivacyChange () { | 183 | private trackPrivacyChange () { |
174 | // We will update the "support" field depending on the channel | 184 | // We will update the "support" field depending on the channel |
175 | this.form.controls[ 'privacy' ] | 185 | this.form.controls[ 'privacy' ] |