aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-watch/comment
diff options
context:
space:
mode:
authorRigel Kent <sendmemail@rigelk.eu>2019-12-16 16:21:42 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-12-17 09:45:02 +0100
commitb29bf61dbd518e5cef0b2f564ddc8f8a0657d089 (patch)
tree86d41fb765ea529095d757e292213156cef7d899 /client/src/app/videos/+video-watch/comment
parentd68ebf0b4a40f88e53a78de6b3109a41466fa7c6 (diff)
downloadPeerTube-b29bf61dbd518e5cef0b2f564ddc8f8a0657d089.tar.gz
PeerTube-b29bf61dbd518e5cef0b2f564ddc8f8a0657d089.tar.zst
PeerTube-b29bf61dbd518e5cef0b2f564ddc8f8a0657d089.zip
Provide native links for description timestamps, and re-clickability for these
Diffstat (limited to 'client/src/app/videos/+video-watch/comment')
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.component.html8
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.component.ts14
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comments.component.html2
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comments.component.ts8
4 files changed, 25 insertions, 7 deletions
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.html b/client/src/app/videos/+video-watch/comment/video-comment.component.html
index 04bb1f7a2..df996533d 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment.component.html
+++ b/client/src/app/videos/+video-watch/comment/video-comment.component.html
@@ -23,7 +23,12 @@
23 <a [routerLink]="['/videos/watch', video.uuid, { 'threadId': comment.threadId }]" 23 <a [routerLink]="['/videos/watch', video.uuid, { 'threadId': comment.threadId }]"
24 class="comment-date">{{ comment.createdAt | myFromNow }}</a> 24 class="comment-date">{{ comment.createdAt | myFromNow }}</a>
25 </div> 25 </div>
26 <div class="comment-html" [innerHTML]="sanitizedCommentHTML"></div> 26 <div
27 class="comment-html"
28 [innerHTML]="sanitizedCommentHTML"
29 (timestampClicked)="handleTimestampClicked($event)"
30 timestampRouteTransformer
31 ></div>
27 32
28 <div class="comment-actions"> 33 <div class="comment-actions">
29 <div *ngIf="isUserLoggedIn()" (click)="onWantToReply()" class="comment-action-reply" i18n>Reply</div> 34 <div *ngIf="isUserLoggedIn()" (click)="onWantToReply()" class="comment-action-reply" i18n>Reply</div>
@@ -65,6 +70,7 @@
65 (wantedToReply)="onWantToReply($event)" 70 (wantedToReply)="onWantToReply($event)"
66 (wantedToDelete)="onWantToDelete($event)" 71 (wantedToDelete)="onWantToDelete($event)"
67 (resetReply)="onResetReply()" 72 (resetReply)="onResetReply()"
73 (timestampClicked)="handleTimestampClicked($event)"
68 ></my-video-comment> 74 ></my-video-comment>
69 </div> 75 </div>
70 </div> 76 </div>
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.ts b/client/src/app/videos/+video-watch/comment/video-comment.component.ts
index d5e3ecc17..b2bf3ee1b 100644
--- a/client/src/app/videos/+video-watch/comment/video-comment.component.ts
+++ b/client/src/app/videos/+video-watch/comment/video-comment.component.ts
@@ -4,7 +4,7 @@ import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/v
4import { AuthService } from '../../../core/auth' 4import { AuthService } from '../../../core/auth'
5import { Video } from '../../../shared/video/video.model' 5import { Video } from '../../../shared/video/video.model'
6import { VideoComment } from './video-comment.model' 6import { VideoComment } from './video-comment.model'
7import { HtmlRendererService, MarkdownService } from '@app/shared/renderer' 7import { MarkdownService } from '@app/shared/renderer'
8 8
9@Component({ 9@Component({
10 selector: 'my-video-comment', 10 selector: 'my-video-comment',
@@ -23,12 +23,12 @@ export class VideoCommentComponent implements OnInit, OnChanges {
23 @Output() wantedToReply = new EventEmitter<VideoComment>() 23 @Output() wantedToReply = new EventEmitter<VideoComment>()
24 @Output() threadCreated = new EventEmitter<VideoCommentThreadTree>() 24 @Output() threadCreated = new EventEmitter<VideoCommentThreadTree>()
25 @Output() resetReply = new EventEmitter() 25 @Output() resetReply = new EventEmitter()
26 @Output() timestampClicked = new EventEmitter<number>()
26 27
27 sanitizedCommentHTML = '' 28 sanitizedCommentHTML = ''
28 newParentComments: VideoComment[] = [] 29 newParentComments: VideoComment[] = []
29 30
30 constructor ( 31 constructor (
31 private htmlRenderer: HtmlRendererService,
32 private markdownService: MarkdownService, 32 private markdownService: MarkdownService,
33 private authService: AuthService 33 private authService: AuthService
34 ) {} 34 ) {}
@@ -78,8 +78,12 @@ export class VideoCommentComponent implements OnInit, OnChanges {
78 this.resetReply.emit() 78 this.resetReply.emit()
79 } 79 }
80 80
81 handleTimestampClicked (timestamp: number) {
82 this.timestampClicked.emit(timestamp)
83 }
84
81 isRemovableByUser () { 85 isRemovableByUser () {
82 return this.isUserLoggedIn() && 86 return this.comment.account && this.isUserLoggedIn() &&
83 ( 87 (
84 this.user.account.id === this.comment.account.id || 88 this.user.account.id === this.comment.account.id ||
85 this.user.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT) 89 this.user.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT)
@@ -87,8 +91,8 @@ export class VideoCommentComponent implements OnInit, OnChanges {
87 } 91 }
88 92
89 private async init () { 93 private async init () {
90 const safeHTML = await this.htmlRenderer.toSafeHtml(this.comment.text) 94 const html = await this.markdownService.textMarkdownToHTML(this.comment.text, true)
91 this.sanitizedCommentHTML = await this.markdownService.processVideoTimestamps(safeHTML) 95 this.sanitizedCommentHTML = await this.markdownService.processVideoTimestamps(html)
92 this.newParentComments = this.parentComments.concat([ this.comment ]) 96 this.newParentComments = this.parentComments.concat([ this.comment ])
93 } 97 }
94} 98}
diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.html b/client/src/app/videos/+video-watch/comment/video-comments.component.html
index 844263ddd..5fabb7dfe 100644
--- a/client/src/app/videos/+video-watch/comment/video-comments.component.html
+++ b/client/src/app/videos/+video-watch/comment/video-comments.component.html
@@ -40,6 +40,7 @@
40 (wantedToDelete)="onWantedToDelete($event)" 40 (wantedToDelete)="onWantedToDelete($event)"
41 (threadCreated)="onThreadCreated($event)" 41 (threadCreated)="onThreadCreated($event)"
42 (resetReply)="onResetReply()" 42 (resetReply)="onResetReply()"
43 (timestampClicked)="handleTimestampClicked($event)"
43 ></my-video-comment> 44 ></my-video-comment>
44 </div> 45 </div>
45 46
@@ -54,6 +55,7 @@
54 (wantedToDelete)="onWantedToDelete($event)" 55 (wantedToDelete)="onWantedToDelete($event)"
55 (threadCreated)="onThreadCreated($event)" 56 (threadCreated)="onThreadCreated($event)"
56 (resetReply)="onResetReply()" 57 (resetReply)="onResetReply()"
58 (timestampClicked)="handleTimestampClicked($event)"
57 ></my-video-comment> 59 ></my-video-comment>
58 60
59 <div *ngIf="comment.totalReplies !== 0 && !threadComments[comment.id]" (click)="viewReplies(comment.id)" class="view-replies"> 61 <div *ngIf="comment.totalReplies !== 0 && !threadComments[comment.id]" (click)="viewReplies(comment.id)" class="view-replies">
diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.ts b/client/src/app/videos/+video-watch/comment/video-comments.component.ts
index cc8b98b4e..e81401553 100644
--- a/client/src/app/videos/+video-watch/comment/video-comments.component.ts
+++ b/client/src/app/videos/+video-watch/comment/video-comments.component.ts
@@ -1,4 +1,4 @@
1import { Component, ElementRef, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewChild } from '@angular/core' 1import { Component, ElementRef, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewChild, Output, EventEmitter } from '@angular/core'
2import { ActivatedRoute } from '@angular/router' 2import { ActivatedRoute } from '@angular/router'
3import { ConfirmService, Notifier } from '@app/core' 3import { ConfirmService, Notifier } from '@app/core'
4import { Subject, Subscription } from 'rxjs' 4import { Subject, Subscription } from 'rxjs'
@@ -24,6 +24,8 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
24 @Input() video: VideoDetails 24 @Input() video: VideoDetails
25 @Input() user: User 25 @Input() user: User
26 26
27 @Output() timestampClicked = new EventEmitter<number>()
28
27 comments: VideoComment[] = [] 29 comments: VideoComment[] = []
28 highlightedThread: VideoComment 30 highlightedThread: VideoComment
29 sort: VideoSortField = '-createdAt' 31 sort: VideoSortField = '-createdAt'
@@ -150,6 +152,10 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
150 this.viewReplies(commentTree.comment.id) 152 this.viewReplies(commentTree.comment.id)
151 } 153 }
152 154
155 handleTimestampClicked (timestamp: number) {
156 this.timestampClicked.emit(timestamp)
157 }
158
153 async onWantedToDelete (commentToDelete: VideoComment) { 159 async onWantedToDelete (commentToDelete: VideoComment) {
154 let message = 'Do you really want to delete this comment?' 160 let message = 'Do you really want to delete this comment?'
155 161