fix tag update

was hanging on tag remove, and wasnt updating if tag count didnt change
v1.18.x
barisusakli 10 years ago
parent 0864480433
commit ee3b0c93c3

@ -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);
});
}

Loading…
Cancel
Save