Skip to content

Commit

Permalink
feat: Add delete thread comment functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Mxchaeltrxn committed Oct 17, 2020
1 parent 7ad7825 commit ca938fb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/mediaPlayer/generateCommentsObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async function generateComments(uploadId){
upload: uploadId,
visibility: 'public',
inResponseTo : {$exists: false}
}).populate({path: 'responses commenter', populate: {path: 'commenter'}});
}).populate({path: 'responses commenter', match: { visibility: { $ne: 'removed' } }, populate: {path: 'commenter'}});

let commentCount = 0;
for(const comment of comments){
Expand Down
2 changes: 1 addition & 1 deletion views/media.pug
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,7 @@ block content
// delete button
// if uploader, admin or commenter, let them delete comment
if isUploaderOrAdmin || ( user && comment.commenter._id == user._id )
a.delete-comment-button(style="margin-left:9px;cursor:pointer;" commentId=comment._id) Delete
a.delete-thread-comment-button(style="margin-left:9px;cursor:pointer;" commentId=responseComment._id) Delete

// if uploader, allow (un)blocking a user
// uploader cannot (un)block themselves
Expand Down
24 changes: 24 additions & 0 deletions views/mediaPlayerPartials/deleteCommentAndBlockUnblockUserJs.pug
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,30 @@ script.
})
})

$('.delete-thread-comment-button').on('release click', function (e) {

var threadComment = $(this).parent().parent().parent();

var commentId = $(this).attr('commentId');

// dont move browser
e.preventDefault();

swal({
title: "Delete Comment",
text: "Are you sure you want to delete the comment?",
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Delete Comment'
}).then(function (result) {
if (result.value) {
deleteComment(commentId, threadComment)
} else {
swal.close();
}
})
})

function blockUser(blockedUsername) {

var csrf = '#{_csrf}'
Expand Down

0 comments on commit ca938fb

Please sign in to comment.