topics.isFollowing works with multiple tids now

v1.18.x
barisusakli 10 years ago
parent f417e07b9d
commit 08c1dad3ee

@ -98,6 +98,7 @@
"updated.message": "This forum has just been updated to the latest version. Click here to refresh the page.",
"privacy": "Privacy",
"follow": "Follow",
"unfollow": "Unfollow",
"delete_all": "Delete All"
}

@ -115,7 +115,7 @@ $(document).ready(function() {
ajaxify.variables.parse();
ajaxify.widgets.render(tpl_url, url, function() {
$(window).trigger('action:ajaxify.end', {url: url});
$(window).trigger('action:ajaxify.end', {url: url, tpl_url: tpl_url});
});
$(window).trigger('action:ajaxify.contentLoaded', {url: url});

@ -539,7 +539,8 @@ app.uid = null;
ajaxify.widgets.render(tpl_url, url, function() {
app.processPage();
$window.trigger('action:ajaxify.end', {
url: url
url: url,
tpl_url: tpl_url
});
});
});

@ -239,11 +239,11 @@ var winston = require('winston'),
if (!exists) {
return next(new Error('[[error:no-topic]]'));
}
topics.isFollowing(tid, uid, next);
topics.isFollowing([tid], uid, next);
},
function (isFollowing, next) {
db[isFollowing ? 'setRemove' : 'setAdd']('tid:' + tid + ':followers', uid, function(err) {
next(err, !isFollowing);
db[isFollowing[0] ? 'setRemove' : 'setAdd']('tid:' + tid + ':followers', uid, function(err) {
next(err, !isFollowing[0]);
});
}
], callback);

@ -234,7 +234,7 @@ var async = require('async'),
category: async.apply(Topics.getCategoryData, tid),
threadTools: async.apply(plugins.fireHook, 'filter:topic.thread_tools', []),
tags: async.apply(Topics.getTopicTagsObjects, tid),
isFollowing: async.apply(Topics.isFollowing, tid, uid)
isFollowing: async.apply(Topics.isFollowing, [tid], uid)
}, function(err, results) {
if (err) {
return callback(err);
@ -244,7 +244,7 @@ var async = require('async'),
topicData.category = results.category;
topicData.thread_tools = results.threadTools;
topicData.tags = results.tags;
topicData.isFollowing = results.isFollowing;
topicData.isFollowing = results.isFollowing[0];
topicData.unreplied = parseInt(topicData.postcount, 10) === 1;
topicData.deleted = parseInt(topicData.deleted, 10) === 1;

@ -14,11 +14,17 @@ var async = require('async'),
module.exports = function(Topics) {
Topics.isFollowing = function(tid, uid, callback) {
Topics.isFollowing = function(tids, uid, callback) {
if (!Array.isArray(tids)) {
return callback();
}
if (!parseInt(uid, 10)) {
return callback(null, false);
return callback(null, tids.map(function() { return false; }));
}
db.isSetMember('tid:' + tid + ':followers', uid, callback);
var keys = tids.map(function(tid) {
return 'tid:' + tid + ':followers';
})
db.isMemberOfSets(keys, uid, callback);
};
Topics.getFollowers = function(tid, callback) {

Loading…
Cancel
Save