Skip to content

Node.js based forum software built for the modern web

closes #670

Baris Soner Usakliea2c03e28b06
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
});
});