Return a promise from the new discussion action

This commit is contained in:
Toby Zerner 2015-06-12 16:40:47 +09:30
parent fe94f2a123
commit 4286243b75

View File

@ -339,16 +339,30 @@ export default class IndexPage extends Component {
/**
* Initialize the composer for a new discussion.
*
* @todo return a promise
* @return void
* @return {Promise}
*/
newDiscussion() {
var deferred = m.deferred();
if (app.session.user()) {
app.composer.load(new DiscussionComposer({ user: app.session.user() }));
app.composer.show();
return true;
this.composeNewDiscussion(deferred);
} else {
app.modal.show(
new LoginModal({ onlogin: this.composeNewDiscussion.bind(this, deferred) })
);
}
app.modal.show(new LoginModal({ onlogin: this.newDiscussion.bind(this) }));
return deferred.promise;
}
composeNewDiscussion(deferred) {
// @todo check global permissions
var component = new DiscussionComposer({ user: app.session.user() });
app.composer.load(component);
app.composer.show();
deferred.resolve(component);
return deferred.promise;
}
/**