diff options
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 | 26 |
1 files changed, 19 insertions, 7 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 b305c639a..9bc9c8844 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,5 +1,6 @@ | |||
1 | import { Component, EventEmitter, Input, Output } from '@angular/core' | 1 | import { Component, EventEmitter, Input, Output } from '@angular/core' |
2 | import { Account as AccountInterface } from '../../../../../../shared/models/actors' | 2 | import { Account as AccountInterface } from '../../../../../../shared/models/actors' |
3 | import { UserRight } from '../../../../../../shared/models/users' | ||
3 | import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' | 4 | import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' |
4 | import { AuthService } from '../../../core/auth' | 5 | import { AuthService } from '../../../core/auth' |
5 | import { Account } from '../../../shared/account/account.model' | 6 | import { Account } from '../../../shared/account/account.model' |
@@ -17,7 +18,9 @@ export class VideoCommentComponent { | |||
17 | @Input() commentTree: VideoCommentThreadTree | 18 | @Input() commentTree: VideoCommentThreadTree |
18 | @Input() inReplyToCommentId: number | 19 | @Input() inReplyToCommentId: number |
19 | 20 | ||
21 | @Output() wantedToDelete = new EventEmitter<VideoComment>() | ||
20 | @Output() wantedToReply = new EventEmitter<VideoComment>() | 22 | @Output() wantedToReply = new EventEmitter<VideoComment>() |
23 | @Output() threadCreated = new EventEmitter<VideoCommentThreadTree>() | ||
21 | @Output() resetReply = new EventEmitter() | 24 | @Output() resetReply = new EventEmitter() |
22 | 25 | ||
23 | constructor (private authService: AuthService) {} | 26 | constructor (private authService: AuthService) {} |
@@ -32,6 +35,8 @@ export class VideoCommentComponent { | |||
32 | comment: this.comment, | 35 | comment: this.comment, |
33 | children: [] | 36 | children: [] |
34 | } | 37 | } |
38 | |||
39 | this.threadCreated.emit(this.commentTree) | ||
35 | } | 40 | } |
36 | 41 | ||
37 | this.commentTree.children.push({ | 42 | this.commentTree.children.push({ |
@@ -41,17 +46,16 @@ export class VideoCommentComponent { | |||
41 | this.resetReply.emit() | 46 | this.resetReply.emit() |
42 | } | 47 | } |
43 | 48 | ||
44 | onWantToReply () { | 49 | onWantToReply (comment?: VideoComment) { |
45 | this.wantedToReply.emit(this.comment) | 50 | this.wantedToReply.emit(comment || this.comment) |
46 | } | 51 | } |
47 | 52 | ||
48 | isUserLoggedIn () { | 53 | onWantToDelete (comment?: VideoComment) { |
49 | return this.authService.isLoggedIn() | 54 | this.wantedToDelete.emit(comment || this.comment) |
50 | } | 55 | } |
51 | 56 | ||
52 | // Event from child comment | 57 | isUserLoggedIn () { |
53 | onWantedToReply (comment: VideoComment) { | 58 | return this.authService.isLoggedIn() |
54 | this.wantedToReply.emit(comment) | ||
55 | } | 59 | } |
56 | 60 | ||
57 | onResetReply () { | 61 | onResetReply () { |
@@ -61,4 +65,12 @@ export class VideoCommentComponent { | |||
61 | getAvatarUrl (account: AccountInterface) { | 65 | getAvatarUrl (account: AccountInterface) { |
62 | return Account.GET_ACCOUNT_AVATAR_URL(account) | 66 | return Account.GET_ACCOUNT_AVATAR_URL(account) |
63 | } | 67 | } |
68 | |||
69 | isRemovableByUser () { | ||
70 | return this.isUserLoggedIn() && | ||
71 | ( | ||
72 | this.user.account.id === this.comment.account.id || | ||
73 | this.user.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT) | ||
74 | ) | ||
75 | } | ||
64 | } | 76 | } |