]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+videos/+video-watch/shared/metadata/video-description.component.ts
Federate entire description
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / +video-watch / shared / metadata / video-description.component.ts
index b5444facb6003e654c2a8808c5c0b8e5ce849234..d0108061103bee479febf21812dd1308796ab53f 100644 (file)
@@ -15,8 +15,10 @@ export class VideoDescriptionComponent implements OnChanges {
 
   descriptionLoading = false
   completeDescriptionShown = false
-  completeVideoDescription: string
-  shortVideoDescription: string
+
+  completeVideoDescriptionLoaded = false
+
+  videoHTMLTruncatedDescription = ''
   videoHTMLDescription = ''
 
   constructor (
@@ -28,22 +30,19 @@ export class VideoDescriptionComponent implements OnChanges {
   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
   }
 
@@ -56,10 +55,10 @@ export class VideoDescriptionComponent implements OnChanges {
             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 => {
@@ -73,15 +72,25 @@ export class VideoDescriptionComponent implements OnChanges {
     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)
+    }
   }
 }