Skip to content

Fix/comments bug #359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
19 changes: 15 additions & 4 deletions views/media.pug
Original file line number Diff line number Diff line change
Expand Up @@ -779,15 +779,15 @@ block content
a(href=`/user/${comment.commenter.channelUrl}` style="color:#d2d2d2;margin-right:5px;") #{comment.commenter.channelName || comment.commenter.channelUrl}
p.fw(style="display:inline-block;") - #{comment.timeAgo} &nbsp
if user && !viewingUserIsBlocked
a.reply-link(style="cursor:pointer") Reply
a.reply-link(style="cursor:pointer") Comment in Thread
// delete button
// if uploader or 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-comment-thread-button(style="margin-left:9px;cursor:pointer;" commentId=comment._id) Delete

if isUploader && !comment.commenter.isBlocked
if isUploader && !comment.commenter.isBlocked && ( user && comment.commenter._id != user._id )
a.block-user-button(style="margin-left:9px;cursor:pointer;" blockedusername=comment.commenter.channelUrl) Block User
if isUploader && comment.commenter.isBlocked
if isUploader && comment.commenter.isBlocked && ( user && comment.commenter._id != user._id )
a.unblock-user-button(style="margin-left:9px;cursor:pointer;" blockedusername=comment.commenter.channelUrl) Unblock User


Expand All @@ -813,6 +813,17 @@ block content
p.fw(style="text-align:left;display:inline-block;")
a(href=`/user/${responseComment.commenter.channelUrl}` style="color:#d2d2d2;margin-right:5px;") #{responseComment.commenter.channelName || responseComment.commenter.channelUrl}
p.fw(style="display:inline-block;") - #{responseComment.timeAgo} &nbsp
// delete button
// if uploader, admin or commenter, let them delete comment
if isUploaderOrAdmin || ( user && comment.commenter._id == user._id )
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
if isUploader && !comment.commenter.isBlocked && ( user && comment.commenter._id != user._id )
a.block-user-button(style="margin-left:9px;cursor:pointer;" blockedusername=comment.commenter.channelUrl) Block User
if isUploader && comment.commenter.isBlocked && ( user && comment.commenter._id != user._id )
a.unblock-user-button(style="margin-left:9px;cursor:pointer;" blockedusername=comment.commenter.channelUrl) Unblock User
p.fw(style="text-align:left;") #{responseComment.text}

//div.reply-container(style="display:none")
Expand Down
30 changes: 27 additions & 3 deletions views/mediaPlayerPartials/deleteCommentAndBlockUnblockUserJs.pug
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
script.
$(function(){
function deleteComment(commentId, commentThread) {
function deleteComment(commentId, comment) {

var upload = '#{upload._id}';

Expand All @@ -21,7 +21,7 @@ script.

swal('Comment deleted!');

commentThread.hide();
comment.hide();


// remove comment
Expand All @@ -36,7 +36,7 @@ script.

}

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

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

Expand All @@ -60,6 +60,30 @@ script.
})
})

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

var commentInThread = $(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, commentInThread)
} else {
swal.close();
}
})
})

function blockUser(blockedUsername) {

var csrf = '#{_csrf}'
Expand Down