diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2019-12-27 10:11:10 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@framasoft.org> | 2019-12-27 10:11:10 +0100 |
commit | edf1a4e5204189f7c352c007232c2463158aa6d7 (patch) | |
tree | 57603f8edfa6b7862ff200f7a70ceb523d4b0d34 /client/src/app/videos/+video-watch/comment/video-comment.component.ts | |
parent | 822c7e610d19e3320519a6ae5c90c01db971f03f (diff) | |
download | PeerTube-edf1a4e5204189f7c352c007232c2463158aa6d7.tar.gz PeerTube-edf1a4e5204189f7c352c007232c2463158aa6d7.tar.zst PeerTube-edf1a4e5204189f7c352c007232c2463158aa6d7.zip |
Add user moderation dropdown to comments
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.ts | 35 |
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 @@ | |||
1 | import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core' | 1 | import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core' |
2 | import { UserRight } from '../../../../../../shared/models/users' | 2 | import { User, UserRight } from '../../../../../../shared/models/users' |
3 | import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' | 3 | import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' |
4 | import { AuthService } from '../../../core/auth' | 4 | import { AuthService } from '@app/core/auth' |
5 | import { Video } from '../../../shared/video/video.model' | 5 | import { AccountService } from '@app/shared/account/account.service' |
6 | import { Video } from '@app/shared/video/video.model' | ||
6 | import { VideoComment } from './video-comment.model' | 7 | import { VideoComment } from './video-comment.model' |
7 | import { MarkdownService } from '@app/shared/renderer' | 8 | import { MarkdownService } from '@app/shared/renderer' |
9 | import { Account } from '@app/shared/account/account.model' | ||
10 | import { Notifier } from '@app/core' | ||
11 | import { 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 | } |