Skip to content

Commit

Permalink
Fix i18n on delete modal and linter
Browse files Browse the repository at this point in the history
  • Loading branch information
kimsible committed Aug 7, 2020
1 parent ce248d9 commit fe02077
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,21 @@ export class VideoCommentComponent implements OnInit, OnChanges {
}

isRedraftableByUser () {
return this.comment.account && this.isUserLoggedIn() && this.user.account.id === this.comment.account.id && this.comment.totalReplies === 0
}

isReportableByUser() {
return this.comment.account && this.isUserLoggedIn() && this.comment.isDeleted === false && this.authService.getUser().account.id !== this.comment.account.id
return (
this.comment.account &&
this.isUserLoggedIn() &&
this.user.account.id === this.comment.account.id &&
this.comment.totalReplies === 0
)
}

isReportableByUser () {
return (
this.comment.account &&
this.isUserLoggedIn() &&
this.comment.isDeleted === false &&
this.authService.getUser().account.id !== this.comment.account.id
)
}

switchToDefaultAvatar ($event: Event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
this.timestampClicked.emit(timestamp)
}

async onWantedToDelete (commentToDelete: VideoComment, message = 'Do you really want to delete this comment?'): Promise<boolean> {
async onWantedToDelete(commentToDelete: VideoComment, title = this.i18n('Delete'), message = this.i18n('Do you really want to delete this comment?')): Promise<boolean> {
if (commentToDelete.isLocal || this.video.isLocal) {
message += this.i18n(' The deletion will be sent to remote instances so they can reflect the change.')
} else {
message += this.i18n(' It is a remote comment, so the deletion will only be effective on your instance.')
}

const res = await this.confirmService.confirm(message, this.i18n('Delete'))
const res = await this.confirmService.confirm(message, title)
if (res === false) return false

this.videoCommentService.deleteVideoComment(commentToDelete.videoId, commentToDelete.id)
Expand All @@ -192,7 +192,7 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
}

async onWantedToRedraft(commentToRedraft: VideoComment) {
const confirm = await this.onWantedToDelete(commentToRedraft, 'Do you really want to delete and re-draft this comment?')
const confirm = await this.onWantedToDelete(commentToRedraft, this.i18n('Delete and re-draft'), this.i18n('Do you really want to delete and re-draft this comment?'))

if (confirm) {
this.inReplyToCommentId = commentToRedraft.inReplyToCommentId
Expand Down

0 comments on commit fe02077

Please sign in to comment.