From c80341655fce5e70ad6da7d812e2ddeb1f8ef7f2 Mon Sep 17 00:00:00 2001 From: clementbrizard Date: Sat, 12 Jan 2019 13:41:45 +0000 Subject: Change models --- client/src/app/shared/video/video-edit.model.ts | 11 ++++++++++- client/src/app/shared/video/video.model.ts | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/video/video-edit.model.ts b/client/src/app/shared/video/video-edit.model.ts index fc772a3cf..9078bb5d2 100644 --- a/client/src/app/shared/video/video-edit.model.ts +++ b/client/src/app/shared/video/video-edit.model.ts @@ -25,6 +25,7 @@ export class VideoEdit implements VideoUpdate { uuid?: string id?: number scheduleUpdate?: VideoScheduleUpdate + originallyPublishedAt?: Date | string constructor (video?: Video & { tags: string[], commentsEnabled: boolean, support: string, thumbnailUrl: string, previewUrl: string }) { if (video) { @@ -46,6 +47,7 @@ export class VideoEdit implements VideoUpdate { this.previewUrl = video.previewUrl this.scheduleUpdate = video.scheduledUpdate + this.originallyPublishedAt = new Date(video.originallyPublishedAt) } } @@ -67,6 +69,12 @@ export class VideoEdit implements VideoUpdate { } else { this.scheduleUpdate = null } + + // Convert originallyPublishedAt to string so that function objectToFormData() works correctly + if (this.originallyPublishedAt) { + const originallyPublishedAt = new Date(values['originallyPublishedAt']) + this.originallyPublishedAt = originallyPublishedAt.toISOString() + } } toFormPatch () { @@ -82,7 +90,8 @@ export class VideoEdit implements VideoUpdate { commentsEnabled: this.commentsEnabled, waitTranscoding: this.waitTranscoding, channelId: this.channelId, - privacy: this.privacy + privacy: this.privacy, + originallyPublishedAt: this.originallyPublishedAt } // Special case if we scheduled an update diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts index b92c96450..c9b052951 100644 --- a/client/src/app/shared/video/video.model.ts +++ b/client/src/app/shared/video/video.model.ts @@ -17,6 +17,7 @@ export class Video implements VideoServerModel { createdAt: Date updatedAt: Date publishedAt: Date + originallyPublishedAt: Date | string category: VideoConstant licence: VideoConstant language: VideoConstant @@ -116,6 +117,9 @@ export class Video implements VideoServerModel { this.privacy.label = peertubeTranslate(this.privacy.label, translations) this.scheduledUpdate = hash.scheduledUpdate + this.originallyPublishedAt = hash.originallyPublishedAt ? + new Date(hash.originallyPublishedAt.toString()) + : null if (this.state) this.state.label = peertubeTranslate(this.state.label, translations) this.blacklisted = hash.blacklisted -- cgit v1.2.3