Skip to content

Commit

Permalink
Revert inlining method, rename the method instead
Browse files Browse the repository at this point in the history
  • Loading branch information
franzliedke committed Jul 3, 2020
1 parent 885300d commit 81fa5bc
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions js/src/forum/components/DiscussionPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,7 @@ export default class DiscussionPage extends Page {
*/
this.near = m.route.param('near') || 0;

const preloadedDiscussion = app.preloadedApiDocument();
if (preloadedDiscussion) {
// We must wrap this in a setTimeout because if we are mounting this
// 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.show.bind(this, preloadedDiscussion), 0);
} else {
const params = this.requestParams();

app.store.find('discussions', m.route.param('id').split('-')[0], params).then(this.show.bind(this));
}

m.lazyRedraw();
this.load();

// If the discussion list has been loaded, then we'll enable the pane (and
// hide it by default). Also, if we've just come from another discussion
Expand Down Expand Up @@ -140,6 +127,26 @@ export default class DiscussionPage extends Page {
}
}

/**
* Load the discussion from the API or use the preloaded one.
*/
load() {
const preloadedDiscussion = app.preloadedApiDocument();
if (preloadedDiscussion) {
// We must wrap this in a setTimeout because if we are mounting this
// 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.show.bind(this, preloadedDiscussion), 0);
} else {
const params = this.requestParams();

app.store.find('discussions', m.route.param('id').split('-')[0], params).then(this.show.bind(this));
}

m.lazyRedraw();
}

/**
* Get the parameters that should be passed in the API request to get the
* discussion.
Expand Down

0 comments on commit 81fa5bc

Please sign in to comment.