mirror of
https://github.com/flarum/framework.git
synced 2024-12-11 21:43:38 +08:00
Return a promise from the new discussion action
This commit is contained in:
parent
fe94f2a123
commit
4286243b75
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user