mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-13 09:25:45 +01:00
fix tag update
was hanging on tag remove, and wasnt updating if tag count didnt change
This commit is contained in:
@@ -107,7 +107,7 @@ define('forum/topic/events', ['forum/topic/browsing', 'forum/topic/postTools', '
|
||||
$(window).trigger('action:posts.edited');
|
||||
});
|
||||
|
||||
if (data.tags && data.tags.length !== $('.tags').first().children().length) {
|
||||
if (data.tags && tagsUpdated(data.tags)) {
|
||||
templates.parse('partials/post_bar', 'tags', {tags: data.tags}, function(html) {
|
||||
var tags = $('.tags');
|
||||
|
||||
@@ -118,6 +118,19 @@ define('forum/topic/events', ['forum/topic/browsing', 'forum/topic/postTools', '
|
||||
}
|
||||
}
|
||||
|
||||
function tagsUpdated(tags) {
|
||||
if (tags.length !== $('.tags').first().children().length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (var i=0; i<tags.length; ++i) {
|
||||
if (!$('.tags .tag-item[data-tag="' + tags[i].value + '"]').length) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function onPostPurged(pid) {
|
||||
$('#post-container li[data-pid="' + pid + '"]').fadeOut(500, function() {
|
||||
$(this).remove();
|
||||
|
||||
@@ -64,9 +64,11 @@ module.exports = function(Topics) {
|
||||
function updateTagCount(tag, callback) {
|
||||
callback = callback || function() {};
|
||||
Topics.getTagTopicCount(tag, function(err, count) {
|
||||
if (!err && count) {
|
||||
db.sortedSetAdd('tags:topic:count', count, tag, callback);
|
||||
if (err || !count) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
db.sortedSetAdd('tags:topic:count', count, tag, callback);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user