From ea2c03e28b062d5e0025d70be92e70d1e525287b Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Fri, 20 Dec 2013 23:35:40 -0500 Subject: [PATCH] closes #670 --- public/src/forum/topic.js | 21 +++++++-------------- src/websockets.js | 4 ++-- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 424d12db2c..1022b098e1 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -1,4 +1,4 @@ -define(function() { +define(['composer'], function(composer) { var Topic = {}, infiniteLoaderActive = false, pagination; @@ -274,9 +274,7 @@ define(function() { } if (thread_state.locked !== '1') { - require(['composer'], function(cmp) { - cmp.push(tid, null, null, selectionText.length > 0 ? selectionText + '\n\n' + username : '' + username); - }); + composer.push(tid, null, null, selectionText.length > 0 ? selectionText + '\n\n' + username : '' + username); } }); @@ -284,15 +282,11 @@ define(function() { if (thread_state.locked !== '1') { var pid = $(this).parents('li').attr('data-pid'); - socket.once('api:posts.getRawPost', function(data) { + socket.emit('api:posts.getRawPost', {pid: pid}, function(data) { quoted = '> ' + data.post.replace(/\n/g, '\n> ') + '\n\n'; - require(['composer'], function(cmp) { - cmp.push(tid, null, null, quoted); - }); - }); - socket.emit('api:posts.getRawPost', { - pid: pid + + composer.push(tid, null, null, quoted); }); } }); @@ -343,9 +337,8 @@ define(function() { $('#post-container').delegate('.edit', 'click', function(e) { var pid = $(this).parents('li').attr('data-pid'); - require(['composer'], function(cmp) { - cmp.push(null, null, pid); - }); + + composer.push(null, null, pid); }); $('#post-container').delegate('.delete', 'click', function(e) { diff --git a/src/websockets.js b/src/websockets.js index 2c2946e1e6..db66b407b3 100644 --- a/src/websockets.js +++ b/src/websockets.js @@ -603,9 +603,9 @@ websockets.init = function(io) { posts.uploadPostImage(data, callback); }); - socket.on('api:posts.getRawPost', function(data) { + socket.on('api:posts.getRawPost', function(data, callback) { posts.getPostField(data.pid, 'content', function(err, raw) { - socket.emit('api:posts.getRawPost', { + callback({ post: raw }); });