-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We can because we don't use the video truncated description since v5.0
- Loading branch information
1 parent
e4f82ea
commit c5f8dc0
Showing
12 changed files
with
58 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 14 additions & 13 deletions
27
client/src/app/+videos/+video-watch/shared/metadata/video-description.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
<div class="video-info-description"> | ||
<div | ||
#descriptionHTML | ||
class="video-info-description-html" | ||
[innerHTML]="getHTMLDescription()" | ||
[ngClass]="{ 'ellipsis-multiline-3': !completeDescriptionShown }" | ||
[innerHTML]="videoHTMLDescription" | ||
(timestampClicked)="onTimestampClicked($event)" | ||
myTimestampRouteTransformer | ||
></div> | ||
|
||
<button | ||
*ngIf="completeDescriptionShown === false && video.description?.length >= 250" | ||
(click)="showMoreDescription()" class="video-info-description-more button-unstyle" | ||
*ngIf="(hasEllipsis() && !completeDescriptionShown) || completeDescriptionShown" | ||
(click)="completeDescriptionShown = !completeDescriptionShown" | ||
class="video-info-description-more button-unstyle" | ||
> | ||
<ng-container i18n>Show more</ng-container> | ||
<span *ngIf="descriptionLoading === false" class="chevron-down"></span> | ||
<my-loader size="sm" class="description-loading" [loading]="descriptionLoading"></my-loader> | ||
</button> | ||
<ng-container *ngIf="!completeDescriptionShown"> | ||
<ng-container i18n>Show more</ng-container> | ||
<span class="chevron-down"></span> | ||
</ng-container> | ||
|
||
<button | ||
*ngIf="completeDescriptionShown === true" | ||
(click)="showLessDescription()" class="video-info-description-more button-unstyle" | ||
> | ||
<ng-container i18n>Show less</ng-container> | ||
<span *ngIf="descriptionLoading === false" class="chevron-up"></span> | ||
<ng-container *ngIf="completeDescriptionShown"> | ||
<ng-container i18n>Show less</ng-container> | ||
<span class="chevron-up"></span> | ||
</ng-container> | ||
</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 14 additions & 55 deletions
69
client/src/app/+videos/+video-watch/shared/metadata/video-description.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,55 @@ | ||
import { Component, EventEmitter, Input, OnChanges, Output } from '@angular/core' | ||
import { MarkdownService, Notifier } from '@app/core' | ||
import { VideoDetails, VideoService } from '@app/shared/shared-main' | ||
import { logger } from '@root-helpers/logger' | ||
import { Component, EventEmitter, Input, OnChanges, Output, ViewChild, ElementRef } from '@angular/core' | ||
import { MarkdownService } from '@app/core' | ||
import { VideoDetails } from '@app/shared/shared-main' | ||
|
||
@Component({ | ||
selector: 'my-video-description', | ||
templateUrl: './video-description.component.html', | ||
styleUrls: [ './video-description.component.scss' ] | ||
}) | ||
export class VideoDescriptionComponent implements OnChanges { | ||
@ViewChild('descriptionHTML') descriptionHTML: ElementRef<HTMLElement> | ||
|
||
@Input() video: VideoDetails | ||
|
||
@Output() timestampClicked = new EventEmitter<number>() | ||
|
||
descriptionLoading = false | ||
completeDescriptionShown = false | ||
|
||
completeVideoDescriptionLoaded = false | ||
|
||
videoHTMLTruncatedDescription = '' | ||
videoHTMLDescription = '' | ||
|
||
constructor ( | ||
private videoService: VideoService, | ||
private notifier: Notifier, | ||
private markdownService: MarkdownService | ||
) { } | ||
|
||
ngOnChanges () { | ||
this.descriptionLoading = false | ||
this.completeDescriptionShown = false | ||
|
||
this.setVideoDescriptionHTML() | ||
} | ||
|
||
showMoreDescription () { | ||
if (!this.completeVideoDescriptionLoaded) { | ||
return this.loadCompleteDescription() | ||
} | ||
hasEllipsis () { | ||
const el = this.descriptionHTML?.nativeElement | ||
if (!el) return false | ||
|
||
return el.offsetHeight < el.scrollHeight | ||
} | ||
|
||
showMoreDescription () { | ||
this.completeDescriptionShown = true | ||
} | ||
|
||
showLessDescription () { | ||
this.completeDescriptionShown = false | ||
} | ||
|
||
loadCompleteDescription () { | ||
this.descriptionLoading = true | ||
|
||
this.videoService.loadCompleteDescription(this.video.descriptionPath) | ||
.subscribe({ | ||
next: description => { | ||
this.completeDescriptionShown = true | ||
this.descriptionLoading = false | ||
|
||
this.video.description = description | ||
|
||
this.setVideoDescriptionHTML() | ||
.catch(err => logger.error(err)) | ||
}, | ||
|
||
error: err => { | ||
this.descriptionLoading = false | ||
this.notifier.error(err.message) | ||
} | ||
}) | ||
} | ||
|
||
onTimestampClicked (timestamp: number) { | ||
this.timestampClicked.emit(timestamp) | ||
} | ||
|
||
getHTMLDescription () { | ||
if (this.completeDescriptionShown) { | ||
return this.videoHTMLDescription | ||
} | ||
|
||
return this.videoHTMLTruncatedDescription | ||
} | ||
|
||
private async setVideoDescriptionHTML () { | ||
{ | ||
const html = await this.markdownService.textMarkdownToHTML({ markdown: this.video.description }) | ||
|
||
this.videoHTMLDescription = this.markdownService.processVideoTimestamps(this.video.shortUUID, html) | ||
} | ||
|
||
{ | ||
const html = await this.markdownService.textMarkdownToHTML({ markdown: this.video.truncatedDescription }) | ||
const html = await this.markdownService.textMarkdownToHTML({ markdown: this.video.description }) | ||
|
||
this.videoHTMLTruncatedDescription = this.markdownService.processVideoTimestamps(this.video.shortUUID, html) | ||
} | ||
this.videoHTMLDescription = this.markdownService.processVideoTimestamps(this.video.shortUUID, html) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters