diff --git a/framework/core/js/forum/src/components/DiscussionPage.js b/framework/core/js/forum/src/components/DiscussionPage.js index e55fc9424..bf8257b71 100644 --- a/framework/core/js/forum/src/components/DiscussionPage.js +++ b/framework/core/js/forum/src/components/DiscussionPage.js @@ -1,4 +1,4 @@ -import Component from 'flarum/Component'; +import Page from 'flarum/components/Page'; import ItemList from 'flarum/utils/ItemList'; import DiscussionHero from 'flarum/components/DiscussionHero'; import PostStream from 'flarum/components/PostStream'; @@ -6,15 +6,13 @@ import PostStreamScrubber from 'flarum/components/PostStreamScrubber'; import LoadingIndicator from 'flarum/components/LoadingIndicator'; import SplitDropdown from 'flarum/components/SplitDropdown'; import listItems from 'flarum/helpers/listItems'; -import mixin from 'flarum/utils/mixin'; -import evented from 'flarum/utils/evented'; import DiscussionControls from 'flarum/utils/DiscussionControls'; /** * The `DiscussionPage` component displays a whole discussion page, including * the discussion list pane, the hero, the posts, and the sidebar. */ -export default class DiscussionPage extends mixin(Component, evented) { +export default class DiscussionPage extends Page { constructor(...args) { super(...args); @@ -43,18 +41,14 @@ export default class DiscussionPage extends mixin(Component, evented) { app.pane.enable(); app.pane.hide(); - if (app.current instanceof DiscussionPage) { + if (app.previous instanceof DiscussionPage) { m.redraw.strategy('diff'); } } - // Push onto the history stack, but use a generalised key so that navigating - // to a few different discussions won't override the behaviour of the back - // button. app.history.push('discussion'); - app.current = this; - app.drawer.hide(); - app.modal.close(); + + this.bodyClass = 'App--discussion'; } onunload(e) { @@ -121,13 +115,6 @@ export default class DiscussionPage extends mixin(Component, evented) { ); } - config(isInitialized, context) { - if (isInitialized) return; - - $('#app').addClass('App--discussion'); - context.onunload = () => $('#app').removeClass('App--discussion'); - } - /** * Clear and reload the discussion. */ @@ -197,8 +184,6 @@ export default class DiscussionPage extends mixin(Component, evented) { this.stream = new PostStream({discussion, includedPosts}); this.stream.on('positionChanged', this.positionChanged.bind(this)); this.stream.goToNumber(m.route.param('near') || includedPosts[0].number(), true); - - this.trigger('loaded', discussion); } /** diff --git a/framework/core/js/forum/src/components/IndexPage.js b/framework/core/js/forum/src/components/IndexPage.js index c260a2d0f..5ba46e216 100644 --- a/framework/core/js/forum/src/components/IndexPage.js +++ b/framework/core/js/forum/src/components/IndexPage.js @@ -1,6 +1,6 @@ -import Component from 'flarum/Component'; +import { extend } from 'flarum/extend'; +import Page from 'flarum/components/Page'; import ItemList from 'flarum/utils/ItemList'; -import affixSidebar from 'flarum/utils/affixSidebar'; import listItems from 'flarum/helpers/listItems'; import DiscussionList from 'flarum/components/DiscussionList'; import WelcomeHero from 'flarum/components/WelcomeHero'; @@ -16,22 +16,22 @@ import SelectDropdown from 'flarum/components/SelectDropdown'; * The `IndexPage` component displays the index page, including the welcome * hero, the sidebar, and the discussion list. */ -export default class IndexPage extends Component { +export default class IndexPage extends Page { constructor(...args) { super(...args); // If the user is returning from a discussion page, then take note of which // discussion they have just visited. After the view is rendered, we will // scroll down so that this discussion is in view. - if (app.current instanceof DiscussionPage) { - this.lastDiscussion = app.current.discussion; + if (app.previous instanceof DiscussionPage) { + this.lastDiscussion = app.previous.discussion; } // If the user is coming from the discussion list, then they have either // just switched one of the parameters (filter, sort, search) or they // probably want to refresh the results. We will clear the discussion list // cache so that results are reloaded. - if (app.current instanceof IndexPage) { + if (app.previous instanceof IndexPage) { app.cache.discussionList = null; } @@ -55,9 +55,8 @@ export default class IndexPage extends Component { } app.history.push('index'); - app.current = this; - app.drawer.hide(); - app.modal.close(); + + this.bodyClass = 'App--index'; } onunload() { @@ -71,7 +70,7 @@ export default class IndexPage extends Component {
{this.hero()}
-