descriptionLoading = false
completeDescriptionShown = false
- completeVideoDescription: string
- shortVideoDescription: string
+
+ completeVideoDescriptionLoaded = false
+
+ videoHTMLTruncatedDescription = ''
videoHTMLDescription = ''
constructor (
ngOnChanges () {
this.descriptionLoading = false
this.completeDescriptionShown = false
- this.completeVideoDescription = undefined
this.setVideoDescriptionHTML()
}
showMoreDescription () {
- if (this.completeVideoDescription === undefined) {
+ if (!this.completeVideoDescriptionLoaded) {
return this.loadCompleteDescription()
}
- this.updateVideoDescription(this.completeVideoDescription)
this.completeDescriptionShown = true
}
showLessDescription () {
- this.updateVideoDescription(this.shortVideoDescription)
this.completeDescriptionShown = false
}
this.completeDescriptionShown = true
this.descriptionLoading = false
- this.shortVideoDescription = this.video.description
- this.completeVideoDescription = description
+ this.video.description = description
- this.updateVideoDescription(this.completeVideoDescription)
+ this.setVideoDescriptionHTML()
+ .catch(err => logger.error(err))
},
error: err => {
this.timestampClicked.emit(timestamp)
}
- private updateVideoDescription (description: string) {
- this.video.description = description
- this.setVideoDescriptionHTML()
- .catch(err => logger.error(err))
+ getHTMLDescription () {
+ if (this.completeDescriptionShown) {
+ return this.videoHTMLDescription
+ }
+
+ return this.videoHTMLTruncatedDescription
}
private async setVideoDescriptionHTML () {
- const html = await this.markdownService.textMarkdownToHTML(this.video.description)
+ {
+ const html = await this.markdownService.textMarkdownToHTML({ markdown: this.video.description })
- this.videoHTMLDescription = this.markdownService.processVideoTimestamps(this.video.shortUUID, html)
+ this.videoHTMLDescription = this.markdownService.processVideoTimestamps(this.video.shortUUID, html)
+ }
+
+ {
+ const html = await this.markdownService.textMarkdownToHTML({ markdown: this.video.truncatedDescription })
+
+ this.videoHTMLTruncatedDescription = this.markdownService.processVideoTimestamps(this.video.shortUUID, html)
+ }
}
}