Skip to content

Commit ca938fb

Browse files
committed
feat: Add delete thread comment functionality
1 parent 7ad7825 commit ca938fb

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

lib/mediaPlayer/generateCommentsObjects.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ async function generateComments(uploadId){
1111
upload: uploadId,
1212
visibility: 'public',
1313
inResponseTo : {$exists: false}
14-
}).populate({path: 'responses commenter', populate: {path: 'commenter'}});
14+
}).populate({path: 'responses commenter', match: { visibility: { $ne: 'removed' } }, populate: {path: 'commenter'}});
1515

1616
let commentCount = 0;
1717
for(const comment of comments){

views/media.pug

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ block content
816816
// delete button
817817
// if uploader, admin or commenter, let them delete comment
818818
if isUploaderOrAdmin || ( user && comment.commenter._id == user._id )
819-
a.delete-comment-button(style="margin-left:9px;cursor:pointer;" commentId=comment._id) Delete
819+
a.delete-thread-comment-button(style="margin-left:9px;cursor:pointer;" commentId=responseComment._id) Delete
820820

821821
// if uploader, allow (un)blocking a user
822822
// uploader cannot (un)block themselves

views/mediaPlayerPartials/deleteCommentAndBlockUnblockUserJs.pug

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,30 @@ script.
6060
})
6161
})
6262

63+
$('.delete-thread-comment-button').on('release click', function (e) {
64+
65+
var threadComment = $(this).parent().parent().parent();
66+
67+
var commentId = $(this).attr('commentId');
68+
69+
// dont move browser
70+
e.preventDefault();
71+
72+
swal({
73+
title: "Delete Comment",
74+
text: "Are you sure you want to delete the comment?",
75+
type: 'warning',
76+
showCancelButton: true,
77+
confirmButtonText: 'Delete Comment'
78+
}).then(function (result) {
79+
if (result.value) {
80+
deleteComment(commentId, threadComment)
81+
} else {
82+
swal.close();
83+
}
84+
})
85+
})
86+
6387
function blockUser(blockedUsername) {
6488

6589
var csrf = '#{_csrf}'

0 commit comments

Comments
 (0)