Implement favourite tooltip to show who favourited a post

This commit is contained in:
MrWaffle
2014-01-22 19:46:34 +01:00
parent baa74958c5
commit b887b76c29
4 changed files with 44 additions and 3 deletions

View File

@@ -115,4 +115,23 @@ var db = require('./database'),
}
};
Favourites.getFavouritedUidsByPids = function (pids, callback) {
//Might as well take the method above this as an example
var loaded = 0;
var data = {};
for (var i = 0, ii = pids.length; i < ii; i++) {
(function (post_id) {
db.getSetMembers('pid:' + post_id + ':users_favourited', function(err, uids) {
data[post_id] = uids;
loaded++;
if (loaded === pids.length) {
callback(data);
}
});
}(pids[i]));
}
//Literally
};
}(exports));