mirror of
https://github.com/flarum/framework.git
synced 2024-12-13 07:03:35 +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.
|
* Initialize the composer for a new discussion.
|
||||||
*
|
*
|
||||||
* @todo return a promise
|
* @return {Promise}
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
newDiscussion() {
|
newDiscussion() {
|
||||||
|
var deferred = m.deferred();
|
||||||
|
|
||||||
if (app.session.user()) {
|
if (app.session.user()) {
|
||||||
app.composer.load(new DiscussionComposer({ user: app.session.user() }));
|
this.composeNewDiscussion(deferred);
|
||||||
app.composer.show();
|
} else {
|
||||||
return true;
|
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