aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-watch/comment/video-comment.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/videos/+video-watch/comment/video-comment.component.ts')
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.component.ts35
1 files changed, 31 insertions, 4 deletions
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 b2bf3ee1b..0d48f0a82 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
@@ -1,10 +1,14 @@
1import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core' 1import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core'
2import { UserRight } from '../../../../../../shared/models/users' 2import { User, UserRight } from '../../../../../../shared/models/users'
3import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' 3import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model'
4import { AuthService } from '../../../core/auth' 4import { AuthService } from '@app/core/auth'
5import { Video } from '../../../shared/video/video.model' 5import { AccountService } from '@app/shared/account/account.service'
6import { Video } from '@app/shared/video/video.model'
6import { VideoComment } from './video-comment.model' 7import { VideoComment } from './video-comment.model'
7import { MarkdownService } from '@app/shared/renderer' 8import { MarkdownService } from '@app/shared/renderer'
9import { Account } from '@app/shared/account/account.model'
10import { Notifier } from '@app/core'
11import { UserService } from '@app/shared'
8 12
9@Component({ 13@Component({
10 selector: 'my-video-comment', 14 selector: 'my-video-comment',
@@ -28,9 +32,15 @@ export class VideoCommentComponent implements OnInit, OnChanges {
28 sanitizedCommentHTML = '' 32 sanitizedCommentHTML = ''
29 newParentComments: VideoComment[] = [] 33 newParentComments: VideoComment[] = []
30 34
35 commentAccount: Account
36 commentUser: User
37
31 constructor ( 38 constructor (
32 private markdownService: MarkdownService, 39 private markdownService: MarkdownService,
33 private authService: AuthService 40 private authService: AuthService,
41 private accountService: AccountService,
42 private userService: UserService,
43 private notifier: Notifier
34 ) {} 44 ) {}
35 45
36 get user () { 46 get user () {
@@ -90,9 +100,26 @@ export class VideoCommentComponent implements OnInit, OnChanges {
90 ) 100 )
91 } 101 }
92 102
103 private getUserIfNeeded (account: Account) {
104 if (!account.userId) return
105 if (!this.authService.isLoggedIn()) return
106
107 const user = this.authService.getUser()
108 if (user.hasRight(UserRight.MANAGE_USERS)) {
109 this.userService.getUser(account.userId)
110 .subscribe(
111 user => this.commentUser = user,
112
113 err => this.notifier.error(err.message)
114 )
115 }
116 }
117
93 private async init () { 118 private async init () {
94 const html = await this.markdownService.textMarkdownToHTML(this.comment.text, true) 119 const html = await this.markdownService.textMarkdownToHTML(this.comment.text, true)
95 this.sanitizedCommentHTML = await this.markdownService.processVideoTimestamps(html) 120 this.sanitizedCommentHTML = await this.markdownService.processVideoTimestamps(html)
96 this.newParentComments = this.parentComments.concat([ this.comment ]) 121 this.newParentComments = this.parentComments.concat([ this.comment ])
122 this.commentAccount = new Account(this.comment.account)
123 this.getUserIfNeeded(this.commentAccount)
97 } 124 }
98} 125}