diff --git a/public/src/forum/category.js b/public/src/forum/category.js index 44138177b2..e71dfc185f 100644 --- a/public/src/forum/category.js +++ b/public/src/forum/category.js @@ -169,13 +169,13 @@ define(['composer', 'forum/pagination', 'share', 'navigator', 'forum/categoryToo } } - Category.onNewTopic = function(data) { - $(window).trigger('filter:categories.new_topic', data.topicData); + Category.onNewTopic = function(topic) { + $(window).trigger('filter:categories.new_topic', topic); ajaxify.loadTemplate('category', function(categoryTemplate) { var html = templates.parse(templates.getBlock(categoryTemplate, 'topics'), { - privileges: data.privileges, - topics: [data.topicData] + privileges: {editable: !!$('.thread-tools').length}, + topics: [topic] }); translator.translate(html, function(translatedHTML) { diff --git a/public/src/modules/composer.js b/public/src/modules/composer.js index 4972eaf3c3..6e57037a47 100644 --- a/public/src/modules/composer.js +++ b/public/src/modules/composer.js @@ -953,7 +953,12 @@ define(['taskbar'], function(taskbar) { content: bodyEl.val(), topic_thumb: thumbEl.val() || '', category_id: postData.cid - }, done); + }, function(err, topic) { + done(err); + if (!err) { + ajaxify.go('topic/' + topic.slug); + } + }); } else if (parseInt(postData.tid, 10) > 0) { socket.emit('posts.reply', { tid: postData.tid, diff --git a/src/socket.io/topics.js b/src/socket.io/topics.js index 7dd8e7c230..af1d835c73 100644 --- a/src/socket.io/topics.js +++ b/src/socket.io/topics.js @@ -32,9 +32,9 @@ SocketTopics.post = function(socket, data, callback) { if (result) { - index.server.sockets.in('category_' + data.category_id).emit('event:new_topic', result); - index.server.sockets.in('recent_posts').emit('event:new_topic', result); - index.server.sockets.in('home').emit('event:new_topic', result); + index.server.sockets.in('category_' + data.category_id).emit('event:new_topic', result.topicData); + index.server.sockets.in('recent_posts').emit('event:new_topic', result.topicData); + index.server.sockets.in('home').emit('event:new_topic', result.topicData); index.server.sockets.in('home').emit('event:new_post', { posts: result.postData }); @@ -44,7 +44,7 @@ SocketTopics.post = function(socket, data, callback) { module.parent.exports.emitTopicPostStats(); - callback(); + callback(null, result.topicData); } }); }; diff --git a/src/topics/create.js b/src/topics/create.js index fe35ac72b6..f597b53d7d 100644 --- a/src/topics/create.js +++ b/src/topics/create.js @@ -82,7 +82,6 @@ module.exports = function(Topics) { return callback(new Error('[[error:title-too-long, ' + meta.config.maximumTitleLength + ']]')); } - var categoryPrivileges; async.waterfall([ function(next) { categoryTools.exists(cid, next); @@ -94,7 +93,6 @@ module.exports = function(Topics) { categoryTools.privileges(cid, uid, next); }, function(privileges, next) { - categoryPrivileges = privileges; if(!privileges.write) { return next(new Error('[[error:no-privileges]]')); } @@ -125,7 +123,6 @@ module.exports = function(Topics) { topicData.unreplied = 1; next(null, { - privileges: categoryPrivileges, topicData: topicData, postData: postData });