mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 22:45:46 +01:00
topics.isFollowing works with multiple tids now
This commit is contained in:
@@ -98,6 +98,7 @@
|
|||||||
"updated.message": "This forum has just been updated to the latest version. Click here to refresh the page.",
|
"updated.message": "This forum has just been updated to the latest version. Click here to refresh the page.",
|
||||||
|
|
||||||
"privacy": "Privacy",
|
"privacy": "Privacy",
|
||||||
|
"follow": "Follow",
|
||||||
|
"unfollow": "Unfollow",
|
||||||
"delete_all": "Delete All"
|
"delete_all": "Delete All"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ $(document).ready(function() {
|
|||||||
ajaxify.variables.parse();
|
ajaxify.variables.parse();
|
||||||
|
|
||||||
ajaxify.widgets.render(tpl_url, url, function() {
|
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});
|
$(window).trigger('action:ajaxify.contentLoaded', {url: url});
|
||||||
|
|||||||
@@ -539,7 +539,8 @@ app.uid = null;
|
|||||||
ajaxify.widgets.render(tpl_url, url, function() {
|
ajaxify.widgets.render(tpl_url, url, function() {
|
||||||
app.processPage();
|
app.processPage();
|
||||||
$window.trigger('action:ajaxify.end', {
|
$window.trigger('action:ajaxify.end', {
|
||||||
url: url
|
url: url,
|
||||||
|
tpl_url: tpl_url
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -239,11 +239,11 @@ var winston = require('winston'),
|
|||||||
if (!exists) {
|
if (!exists) {
|
||||||
return next(new Error('[[error:no-topic]]'));
|
return next(new Error('[[error:no-topic]]'));
|
||||||
}
|
}
|
||||||
topics.isFollowing(tid, uid, next);
|
topics.isFollowing([tid], uid, next);
|
||||||
},
|
},
|
||||||
function (isFollowing, next) {
|
function (isFollowing, next) {
|
||||||
db[isFollowing ? 'setRemove' : 'setAdd']('tid:' + tid + ':followers', uid, function(err) {
|
db[isFollowing[0] ? 'setRemove' : 'setAdd']('tid:' + tid + ':followers', uid, function(err) {
|
||||||
next(err, !isFollowing);
|
next(err, !isFollowing[0]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
], callback);
|
], callback);
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ var async = require('async'),
|
|||||||
category: async.apply(Topics.getCategoryData, tid),
|
category: async.apply(Topics.getCategoryData, tid),
|
||||||
threadTools: async.apply(plugins.fireHook, 'filter:topic.thread_tools', []),
|
threadTools: async.apply(plugins.fireHook, 'filter:topic.thread_tools', []),
|
||||||
tags: async.apply(Topics.getTopicTagsObjects, tid),
|
tags: async.apply(Topics.getTopicTagsObjects, tid),
|
||||||
isFollowing: async.apply(Topics.isFollowing, tid, uid)
|
isFollowing: async.apply(Topics.isFollowing, [tid], uid)
|
||||||
}, function(err, results) {
|
}, function(err, results) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
@@ -244,7 +244,7 @@ var async = require('async'),
|
|||||||
topicData.category = results.category;
|
topicData.category = results.category;
|
||||||
topicData.thread_tools = results.threadTools;
|
topicData.thread_tools = results.threadTools;
|
||||||
topicData.tags = results.tags;
|
topicData.tags = results.tags;
|
||||||
topicData.isFollowing = results.isFollowing;
|
topicData.isFollowing = results.isFollowing[0];
|
||||||
|
|
||||||
topicData.unreplied = parseInt(topicData.postcount, 10) === 1;
|
topicData.unreplied = parseInt(topicData.postcount, 10) === 1;
|
||||||
topicData.deleted = parseInt(topicData.deleted, 10) === 1;
|
topicData.deleted = parseInt(topicData.deleted, 10) === 1;
|
||||||
|
|||||||
@@ -14,11 +14,17 @@ var async = require('async'),
|
|||||||
module.exports = function(Topics) {
|
module.exports = function(Topics) {
|
||||||
|
|
||||||
|
|
||||||
Topics.isFollowing = function(tid, uid, callback) {
|
Topics.isFollowing = function(tids, uid, callback) {
|
||||||
if (!parseInt(uid, 10)) {
|
if (!Array.isArray(tids)) {
|
||||||
return callback(null, false);
|
return callback();
|
||||||
}
|
}
|
||||||
db.isSetMember('tid:' + tid + ':followers', uid, callback);
|
if (!parseInt(uid, 10)) {
|
||||||
|
return callback(null, tids.map(function() { return false; }));
|
||||||
|
}
|
||||||
|
var keys = tids.map(function(tid) {
|
||||||
|
return 'tid:' + tid + ':followers';
|
||||||
|
})
|
||||||
|
db.isMemberOfSets(keys, uid, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
Topics.getFollowers = function(tid, callback) {
|
Topics.getFollowers = function(tid, callback) {
|
||||||
|
|||||||
Reference in New Issue
Block a user