aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+videos/+video-watch/shared/metadata/video-description.component.ts')
-rw-r--r--client/src/app/+videos/+video-watch/shared/metadata/video-description.component.ts39
1 files changed, 24 insertions, 15 deletions
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.ts b/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.ts
index 72b09a274..d01080611 100644
--- a/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.ts
+++ b/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.ts
@@ -15,8 +15,10 @@ export class VideoDescriptionComponent implements OnChanges {
15 15
16 descriptionLoading = false 16 descriptionLoading = false
17 completeDescriptionShown = false 17 completeDescriptionShown = false
18 completeVideoDescription: string 18
19 shortVideoDescription: string 19 completeVideoDescriptionLoaded = false
20
21 videoHTMLTruncatedDescription = ''
20 videoHTMLDescription = '' 22 videoHTMLDescription = ''
21 23
22 constructor ( 24 constructor (
@@ -28,22 +30,19 @@ export class VideoDescriptionComponent implements OnChanges {
28 ngOnChanges () { 30 ngOnChanges () {
29 this.descriptionLoading = false 31 this.descriptionLoading = false
30 this.completeDescriptionShown = false 32 this.completeDescriptionShown = false
31 this.completeVideoDescription = undefined
32 33
33 this.setVideoDescriptionHTML() 34 this.setVideoDescriptionHTML()
34 } 35 }
35 36
36 showMoreDescription () { 37 showMoreDescription () {
37 if (this.completeVideoDescription === undefined) { 38 if (!this.completeVideoDescriptionLoaded) {
38 return this.loadCompleteDescription() 39 return this.loadCompleteDescription()
39 } 40 }
40 41
41 this.updateVideoDescription(this.completeVideoDescription)
42 this.completeDescriptionShown = true 42 this.completeDescriptionShown = true
43 } 43 }
44 44
45 showLessDescription () { 45 showLessDescription () {
46 this.updateVideoDescription(this.shortVideoDescription)
47 this.completeDescriptionShown = false 46 this.completeDescriptionShown = false
48 } 47 }
49 48
@@ -56,10 +55,10 @@ export class VideoDescriptionComponent implements OnChanges {
56 this.completeDescriptionShown = true 55 this.completeDescriptionShown = true
57 this.descriptionLoading = false 56 this.descriptionLoading = false
58 57
59 this.shortVideoDescription = this.video.description 58 this.video.description = description
60 this.completeVideoDescription = description
61 59
62 this.updateVideoDescription(this.completeVideoDescription) 60 this.setVideoDescriptionHTML()
61 .catch(err => logger.error(err))
63 }, 62 },
64 63
65 error: err => { 64 error: err => {
@@ -73,15 +72,25 @@ export class VideoDescriptionComponent implements OnChanges {
73 this.timestampClicked.emit(timestamp) 72 this.timestampClicked.emit(timestamp)
74 } 73 }
75 74
76 private updateVideoDescription (description: string) { 75 getHTMLDescription () {
77 this.video.description = description 76 if (this.completeDescriptionShown) {
78 this.setVideoDescriptionHTML() 77 return this.videoHTMLDescription
79 .catch(err => logger.error(err)) 78 }
79
80 return this.videoHTMLTruncatedDescription
80 } 81 }
81 82
82 private async setVideoDescriptionHTML () { 83 private async setVideoDescriptionHTML () {
83 const html = await this.markdownService.textMarkdownToHTML({ markdown: this.video.description }) 84 {
85 const html = await this.markdownService.textMarkdownToHTML({ markdown: this.video.description })
84 86
85 this.videoHTMLDescription = this.markdownService.processVideoTimestamps(this.video.shortUUID, html) 87 this.videoHTMLDescription = this.markdownService.processVideoTimestamps(this.video.shortUUID, html)
88 }
89
90 {
91 const html = await this.markdownService.textMarkdownToHTML({ markdown: this.video.truncatedDescription })
92
93 this.videoHTMLTruncatedDescription = this.markdownService.processVideoTimestamps(this.video.shortUUID, html)
94 }
86 } 95 }
87} 96}