mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
dont closed composer if callback isn't called
This commit is contained in:
9
app.js
9
app.js
@@ -94,11 +94,8 @@
|
||||
|
||||
var templates = require('./public/src/templates'),
|
||||
translator = require('./public/src/translator'),
|
||||
webserver = require('./src/webserver');
|
||||
console.log('here now');
|
||||
// SocketIO = require('socket.io').listen(global.server, { log: false, transports: ['websocket', 'xhr-polling', 'jsonp-polling', 'flashsocket'], 'browser client minification': true}),
|
||||
// websockets = require('./src/websockets'),
|
||||
var sockets = require('./src/socket.io'),
|
||||
webserver = require('./src/webserver'),
|
||||
sockets = require('./src/socket.io'),
|
||||
plugins = require('./src/plugins'),
|
||||
notifications = require('./src/notifications'),
|
||||
upgrade = require('./src/upgrade');
|
||||
@@ -107,7 +104,7 @@
|
||||
|
||||
upgrade.check(function(schema_ok) {
|
||||
if (schema_ok || nconf.get('check-schema') === false) {
|
||||
// websockets.init(SocketIO);
|
||||
|
||||
sockets.init();
|
||||
|
||||
plugins.init();
|
||||
|
||||
@@ -434,21 +434,25 @@ define(['taskbar'], function(taskbar) {
|
||||
'title' : titleEl.val(),
|
||||
'content' : bodyEl.val(),
|
||||
'category_id' : postData.cid
|
||||
}, function() {
|
||||
composer.discard(post_uuid);
|
||||
});
|
||||
} else if (parseInt(postData.tid) > 0) {
|
||||
socket.emit('api:posts.reply', {
|
||||
'topic_id' : postData.tid,
|
||||
'content' : bodyEl.val()
|
||||
}, function() {
|
||||
composer.discard(post_uuid);
|
||||
});
|
||||
} else if (parseInt(postData.pid) > 0) {
|
||||
socket.emit('api:posts.edit', {
|
||||
pid: postData.pid,
|
||||
content: bodyEl.val(),
|
||||
title: titleEl.val()
|
||||
}, function() {
|
||||
composer.discard(post_uuid);
|
||||
});
|
||||
}
|
||||
|
||||
composer.discard(post_uuid);
|
||||
}
|
||||
|
||||
function composerAlert(title, message) {
|
||||
|
||||
@@ -120,6 +120,7 @@ Sockets.init = function() {
|
||||
});
|
||||
|
||||
socket.on('*', function(payload, callback) {
|
||||
console.log(this.event);
|
||||
// Ignore all non-api messages
|
||||
if (payload.name.substr(0, 4) !== 'api:') {
|
||||
return;
|
||||
|
||||
@@ -6,7 +6,7 @@ var posts = require('../posts'),
|
||||
|
||||
SocketPosts = {};
|
||||
|
||||
SocketPosts.reply = function(data, sessionData) {
|
||||
SocketPosts.reply = function(data, callback, sessionData) {
|
||||
if (sessionData.uid < 1 && parseInt(meta.config.allowGuestPosting, 10) === 0) {
|
||||
sessionData.socket.emit('event:alert', {
|
||||
title: 'Reply Unsuccessful',
|
||||
@@ -17,12 +17,6 @@ SocketPosts.reply = function(data, sessionData) {
|
||||
return;
|
||||
}
|
||||
|
||||
// FIXME: postDelay in sockets? I am disappoint.
|
||||
// if (Date.now() - lastPostTime < meta.config.postDelay * 1000) {
|
||||
// module.parent.exports.emitTooManyPostsAlert(sessionData.socket);
|
||||
// return;
|
||||
// }
|
||||
|
||||
topics.reply(data.topic_id, sessionData.uid, data.content, function(err, postData) {
|
||||
if(err) {
|
||||
if (err.message === 'content-too-short') {
|
||||
@@ -48,7 +42,7 @@ SocketPosts.reply = function(data, sessionData) {
|
||||
}
|
||||
|
||||
if (postData) {
|
||||
lastPostTime = Date.now();
|
||||
|
||||
module.parent.exports.emitTopicPostStats();
|
||||
|
||||
sessionData.socket.emit('event:alert', {
|
||||
@@ -63,7 +57,7 @@ SocketPosts.reply = function(data, sessionData) {
|
||||
sessionData.server.sockets.in('topic_' + postData.tid).emit('event:new_post', socketData);
|
||||
sessionData.server.sockets.in('recent_posts').emit('event:new_post', socketData);
|
||||
sessionData.server.sockets.in('user/' + postData.uid).emit('event:new_post', socketData);
|
||||
|
||||
callback();
|
||||
}
|
||||
|
||||
});
|
||||
@@ -93,7 +87,7 @@ SocketPosts.getRawPost = function(data, callback) {
|
||||
});
|
||||
};
|
||||
|
||||
SocketPosts.edit = function(data, sessionData) {
|
||||
SocketPosts.edit = function(data, callback, sessionData) {
|
||||
if(!sessionData.uid) {
|
||||
sessionData.socket.emit('event:alert', {
|
||||
title: 'Can't edit',
|
||||
@@ -111,6 +105,7 @@ SocketPosts.edit = function(data, sessionData) {
|
||||
}
|
||||
|
||||
postTools.edit(sessionData.uid, data.pid, data.title, data.content, data.images);
|
||||
callback();
|
||||
};
|
||||
|
||||
SocketPosts.delete = function(data, callback, sessionData) {
|
||||
|
||||
@@ -3,7 +3,7 @@ var topics = require('../topics'),
|
||||
|
||||
SocketTopics = {};
|
||||
|
||||
SocketTopics.post = function(data, sessionData) {
|
||||
SocketTopics.post = function(data, callback, sessionData) {
|
||||
if (sessionData.uid < 1 && parseInt(meta.config.allowGuestPosting, 10) === 0) {
|
||||
socket.emit('event:alert', {
|
||||
title: 'Post Unsuccessful',
|
||||
@@ -57,6 +57,7 @@ SocketTopics.post = function(data, sessionData) {
|
||||
type: 'success',
|
||||
timeout: 2000
|
||||
});
|
||||
callback();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user