Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
getUpvoters works with array
  • Loading branch information
barisusakli committed Jan 19, 2015
1 parent cb5ee2a commit 2f955c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
10 changes: 5 additions & 5 deletions public/src/client/topic/postTools.js
Expand Up @@ -39,15 +39,15 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com

function addVoteHandler() {
$('#post-container').on('mouseenter', '.post-row .votes', function() {
loadDataAndCreateTooltip($(this), 'posts.getUpvoters');
loadDataAndCreateTooltip($(this));
});
}

function loadDataAndCreateTooltip(el, method) {
function loadDataAndCreateTooltip(el) {
var pid = el.parents('.post-row').attr('data-pid');
socket.emit(method, pid, function(err, data) {
if (!err) {
createTooltip(el, data);
socket.emit('posts.getUpvoters', [pid], function(err, data) {
if (!err && data.length) {
createTooltip(el, data[0]);
}
});
}
Expand Down
7 changes: 5 additions & 2 deletions src/socket.io/posts.js
Expand Up @@ -339,8 +339,11 @@ SocketPosts.getPrivileges = function(socket, pids, callback) {
});
};

SocketPosts.getUpvoters = function(socket, pid, callback) {
favourites.getUpvotedUidsByPids([pid], function(err, data) {
SocketPosts.getUpvoters = function(socket, pids, callback) {
if (!Array.isArray(pids)) {
return callback(new Error('[[error:invalid-data]]'));
}
favourites.getUpvotedUidsByPids(pids, function(err, data) {
if (err || !Array.isArray(data) || !data.length) {
return callback(err, []);
}
Expand Down

0 comments on commit 2f955c3

Please sign in to comment.