Add 'state helpers', shortcuts to make querying app state easier

This commit is contained in:
Toby Zerner 2015-06-01 10:26:23 +09:30
parent 220190cc53
commit b1693f9537
2 changed files with 16 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import App from 'flarum/utils/app';
import store from 'flarum/initializers/store';
import stateHelpers from 'flarum/initializers/state-helpers';
import discussionControls from 'flarum/initializers/discussion-controls';
import postControls from 'flarum/initializers/post-controls';
import preload from 'flarum/initializers/preload';
@ -12,6 +13,7 @@ import boot from 'flarum/initializers/boot';
var app = new App();
app.initializers.add('store', store);
app.initializers.add('state-helpers', stateHelpers);
app.initializers.add('discussion-controls', discussionControls);
app.initializers.add('post-controls', postControls);
app.initializers.add('session', session);

View File

@ -0,0 +1,14 @@
import ReplyComposer from 'flarum/components/reply-composer';
import DiscussionPage from 'flarum/components/discussion-page';
export default function(app) {
app.composingReplyTo = function(discussion) {
return this.composer.component instanceof ReplyComposer &&
this.composer.component.props.discussion === discussion;
};
app.viewingDiscussion = function(discussion) {
return this.current instanceof DiscussionPage &&
this.current.discussion() === discussion;
};
};