Composer: simplify code with early returns

v1.18.x
Micheil Smith 11 years ago
parent 9dc0a4b115
commit 78e1e4fbac

@ -415,7 +415,10 @@ define(['taskbar'], function(taskbar) {
}
composer.newTopic = function(cid) {
if(allowed()) {
if(!allowed()) {
return;
}
push({
cid: cid,
title: '',
@ -423,13 +426,20 @@ define(['taskbar'], function(taskbar) {
modified: false,
isMain: true
});
}
};
composer.addQuote = function(tid, pid, title, username, text){
if (allowed()) {
if (!allowed()) {
return;
}
var uuid = composer.active;
if(uuid !== undefined){
if(uuid === undefined){
composer.newReply(tid, pid, title, username + ' said:\n' + text);
return;
}
var bodyEl = $('#cmp-uuid-'+uuid).find('textarea');
var prevText = bodyEl.val();
if(tid !== composer.posts[uuid].tid) {
@ -439,14 +449,13 @@ define(['taskbar'], function(taskbar) {
}
composer.posts[uuid].body = (prevText.length ? prevText + '\n\n' : '') + text;
bodyEl.val(composer.posts[uuid].body);
} else {
composer.newReply(tid, pid, title, username + ' said:\n' + text);
}
}
};
composer.newReply = function(tid, pid, title, text) {
if(allowed()) {
if(!allowed()) {
return;
}
push({
tid: tid,
toPid: pid,
@ -455,15 +464,18 @@ define(['taskbar'], function(taskbar) {
modified: false,
isMain: false
});
}
};
composer.editPost = function(pid) {
if(allowed()) {
if(!allowed()) {
return;
}
socket.emit('modules.composer.push', pid, function(err, threadData) {
if(err) {
return app.alertError(err.message);
}
push({
pid: pid,
title: threadData.title,
@ -473,7 +485,6 @@ define(['taskbar'], function(taskbar) {
topic_thumb: threadData.topic_thumb
});
});
}
};
composer.load = function(post_uuid) {

Loading…
Cancel
Save