mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-24 01:10:31 +01:00
getUpvoters works with array
This commit is contained in:
@@ -39,15 +39,15 @@ define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(com
|
|||||||
|
|
||||||
function addVoteHandler() {
|
function addVoteHandler() {
|
||||||
$('#post-container').on('mouseenter', '.post-row .votes', function() {
|
$('#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');
|
var pid = el.parents('.post-row').attr('data-pid');
|
||||||
socket.emit(method, pid, function(err, data) {
|
socket.emit('posts.getUpvoters', [pid], function(err, data) {
|
||||||
if (!err) {
|
if (!err && data.length) {
|
||||||
createTooltip(el, data);
|
createTooltip(el, data[0]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -339,8 +339,11 @@ SocketPosts.getPrivileges = function(socket, pids, callback) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
SocketPosts.getUpvoters = function(socket, pid, callback) {
|
SocketPosts.getUpvoters = function(socket, pids, callback) {
|
||||||
favourites.getUpvotedUidsByPids([pid], function(err, data) {
|
if (!Array.isArray(pids)) {
|
||||||
|
return callback(new Error('[[error:invalid-data]]'));
|
||||||
|
}
|
||||||
|
favourites.getUpvotedUidsByPids(pids, function(err, data) {
|
||||||
if (err || !Array.isArray(data) || !data.length) {
|
if (err || !Array.isArray(data) || !data.length) {
|
||||||
return callback(err, []);
|
return callback(err, []);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user