mirror of
https://github.com/flarum/framework.git
synced 2024-12-24 15:24:03 +08:00
ab6c03c0cc
- Use JSX for templates - Docblock/comment everything - Mostly passes ESLint (still some work to do) - Lots of renaming, refactoring, etc. CSS hasn't been updated yet.
87 lines
2.0 KiB
JavaScript
87 lines
2.0 KiB
JavaScript
import History from 'flarum/utils/History';
|
|
import App from 'flarum/App';
|
|
import Search from 'flarum/components/Search';
|
|
import Composer from 'flarum/components/Composer';
|
|
import ReplyComposer from 'flarum/components/ReplyComposer';
|
|
import DiscussionPage from 'flarum/components/DiscussionPage';
|
|
|
|
export default class ForumApp extends App {
|
|
constructor(...args) {
|
|
super(...args);
|
|
|
|
/**
|
|
* The app's history stack, which keeps track of which routes the user visits
|
|
* so that they can easily navigate back to the previous route.
|
|
*
|
|
* @type {History}
|
|
*/
|
|
this.history = new History();
|
|
|
|
/**
|
|
* An object which controls the state of the page's side pane.
|
|
*
|
|
* @type {Pane}
|
|
*/
|
|
this.pane = null;
|
|
|
|
/**
|
|
* The page's search component instance.
|
|
*
|
|
* @type {SearchBox}
|
|
*/
|
|
this.search = new Search();
|
|
|
|
/**
|
|
* An object which controls the state of the page's drawer.
|
|
*
|
|
* @type {Drawer}
|
|
*/
|
|
this.drawer = null;
|
|
|
|
/**
|
|
* A map of post types to their components.
|
|
*
|
|
* @type {Object}
|
|
*/
|
|
this.postComponents = {};
|
|
|
|
/**
|
|
* A map of activity types to their components.
|
|
*
|
|
* @type {Object}
|
|
*/
|
|
this.activityComponents = {};
|
|
|
|
/**
|
|
* A map of notification types to their components.
|
|
*
|
|
* @type {Object}
|
|
*/
|
|
this.notificationComponents = {};
|
|
}
|
|
|
|
/**
|
|
* Check whether or not the user is currently composing a reply to a
|
|
* discussion.
|
|
*
|
|
* @param {Discussion} discussion
|
|
* @return {Boolean}
|
|
*/
|
|
composingReplyTo(discussion) {
|
|
return this.composer.component instanceof ReplyComposer &&
|
|
this.composer.component.props.discussion === discussion &&
|
|
this.composer.position !== Composer.PositionEnum.HIDDEN;
|
|
}
|
|
|
|
/**
|
|
* Check whether or not the user is currently viewing a discussion.
|
|
*
|
|
* @param {Discussion} discussion
|
|
* @return {Boolean}
|
|
*/
|
|
viewingDiscussion(discussion) {
|
|
return this.current instanceof DiscussionPage &&
|
|
this.current.discussion === discussion;
|
|
}
|
|
}
|