diff --git a/js/forum/src/components/DiscussionPage.js b/js/forum/src/components/DiscussionPage.js index c51d7792ff..df815c2520 100644 --- a/js/forum/src/components/DiscussionPage.js +++ b/js/forum/src/components/DiscussionPage.js @@ -128,12 +128,12 @@ export default class DiscussionPage extends Page { // component for the first time on page load, then any calls to m.redraw // will be ineffective and thus any configs (scroll code) will be run // before stuff is drawn to the page. - setTimeout(this.init.bind(this, preloadedDiscussion)); + setTimeout(this.show.bind(this, preloadedDiscussion)); } else { const params = this.requestParams(); app.store.find('discussions', m.route.param('id').split('-')[0], params) - .then(this.init.bind(this)); + .then(this.show.bind(this)); } m.lazyRedraw(); @@ -156,7 +156,7 @@ export default class DiscussionPage extends Page { * * @param {Discussion} discussion */ - init(discussion) { + show(discussion) { this.discussion = discussion; app.setTitle(discussion.title()); diff --git a/js/forum/src/components/PostStream.js b/js/forum/src/components/PostStream.js index ddfb28bd00..ea0a97a720 100644 --- a/js/forum/src/components/PostStream.js +++ b/js/forum/src/components/PostStream.js @@ -38,7 +38,7 @@ class PostStream extends mixin(Component, evented) { this.loadPageTimeouts = {}; this.pagesLoading = 0; - this.init(this.props.includedPosts); + this.show(this.props.includedPosts); } /** @@ -153,7 +153,7 @@ class PostStream extends mixin(Component, evented) { * * @param {Post[]} posts */ - init(posts) { + show(posts) { this.visibleStart = posts.length ? this.discussion.postIds().indexOf(posts[0].id()) : 0; this.visibleEnd = this.visibleStart + posts.length; } @@ -421,7 +421,7 @@ class PostStream extends mixin(Component, evented) { return app.store.find('posts', { filter: {discussion: this.discussion.id()}, page: {near: number} - }).then(this.init.bind(this)); + }).then(this.show.bind(this)); } /** @@ -442,7 +442,7 @@ class PostStream extends mixin(Component, evented) { this.reset(start, end); - return this.loadRange(start, end).then(this.init.bind(this)); + return this.loadRange(start, end).then(this.show.bind(this)); } /** diff --git a/js/forum/src/components/PostsUserPage.js b/js/forum/src/components/PostsUserPage.js index ede930842a..d08a3f3e18 100644 --- a/js/forum/src/components/PostsUserPage.js +++ b/js/forum/src/components/PostsUserPage.js @@ -80,8 +80,8 @@ export default class PostsUserPage extends UserPage { * Initialize the component with a user, and trigger the loading of their * activity feed. */ - init(user) { - super.init(user); + show(user) { + super.show(user); this.refresh(); } diff --git a/js/forum/src/components/SettingsPage.js b/js/forum/src/components/SettingsPage.js index 31180d0152..e2d15b9af0 100644 --- a/js/forum/src/components/SettingsPage.js +++ b/js/forum/src/components/SettingsPage.js @@ -16,7 +16,7 @@ export default class SettingsPage extends UserPage { constructor(...args) { super(...args); - this.init(app.session.user); + this.show(app.session.user); app.setTitle(app.trans('core.settings')); } diff --git a/js/forum/src/components/UserPage.js b/js/forum/src/components/UserPage.js index 2d3158ea12..fea80cb034 100644 --- a/js/forum/src/components/UserPage.js +++ b/js/forum/src/components/UserPage.js @@ -71,7 +71,7 @@ export default class UserPage extends Page { * @param {User} user * @protected */ - init(user) { + show(user) { this.user = user; app.setTitle(user.username()); @@ -90,13 +90,13 @@ export default class UserPage extends Page { app.store.all('users').some(user => { if (user.username().toLowerCase() === lowercaseUsername && user.joinTime()) { - this.init(user); + this.show(user); return true; } }); if (!this.user) { - app.store.find('users', username).then(this.init.bind(this)); + app.store.find('users', username).then(this.show.bind(this)); } } diff --git a/js/lib/Component.js b/js/lib/Component.js index 9c622129ed..8f36306ea4 100644 --- a/js/lib/Component.js +++ b/js/lib/Component.js @@ -53,6 +53,16 @@ export default class Component { * @public */ this.element = null; + + this.init(); + } + + /** + * Called when the component is constructed. + * + * @protected + */ + init() { } /**