mirror of
https://github.com/flarum/core.git
synced 2025-10-12 07:24:27 +02:00
Add init hook as a way to effectively monkey patch constructors
Related to #246
This commit is contained in:
@@ -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());
|
||||
|
Reference in New Issue
Block a user