diff --git a/framework/core/js/forum/src/app.js b/framework/core/js/forum/src/app.js index 9aa36238f..d68d374ef 100644 --- a/framework/core/js/forum/src/app.js +++ b/framework/core/js/forum/src/app.js @@ -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); diff --git a/framework/core/js/forum/src/initializers/state-helpers.js b/framework/core/js/forum/src/initializers/state-helpers.js new file mode 100644 index 000000000..3363a6ff6 --- /dev/null +++ b/framework/core/js/forum/src/initializers/state-helpers.js @@ -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; + }; +};