From f4001cf408a99049d01a356bfb20a62342de06ea Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 16 Jul 2018 14:22:16 +0200 Subject: Handle .srt subtitles --- .../videos/+video-edit/shared/video-edit.component.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'client/src/app/videos/+video-edit/shared/video-edit.component.ts') 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 9394d7dab..c7beccb30 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 @@ -68,6 +68,12 @@ export class VideoEditComponent implements OnInit, OnDestroy { this.calendarDateFormat = this.i18nPrimengCalendarService.getDateFormat() } + get existingCaptions () { + return this.videoCaptions + .filter(c => c.action !== 'REMOVE') + .map(c => c.language.id) + } + updateForm () { const defaultValues = { nsfw: 'false', @@ -126,11 +132,15 @@ export class VideoEditComponent implements OnInit, OnDestroy { if (this.schedulerInterval) clearInterval(this.schedulerInterval) } - getExistingCaptions () { - return this.videoCaptions.map(c => c.language.id) - } - onCaptionAdded (caption: VideoCaptionEdit) { + const existingCaption = this.videoCaptions.find(c => c.language.id === caption.language.id) + + // Replace existing caption? + if (existingCaption) { + Object.assign(existingCaption, caption, { action: 'CREATE' as 'CREATE' }) + return + } + this.videoCaptions.push( Object.assign(caption, { action: 'CREATE' as 'CREATE' }) ) -- cgit v1.2.3