Node.js based forum software built for the modern web
fix tag update
barisusakliee3b0c93c3fe
diff --git a/public/src/client/topic/events.js b/public/src/client/topic/events.jsindex 055594bbf8..1318ae23df 100644--- a/public/src/client/topic/events.js+++ b/public/src/client/topic/events.js@@ -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();diff --git a/src/topics/tags.js b/src/topics/tags.jsindex 0999584498..c9e341d926 100644--- a/src/topics/tags.js+++ b/src/topics/tags.js@@ -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);});}