Add ability to refresh index page by clicking on logo. closes flarum/core#188

This commit is contained in:
Toby Zerner 2015-07-28 12:27:45 +09:30
parent c5fd4418fb
commit 4f5e1d4aa3
2 changed files with 9 additions and 15 deletions

View File

@ -27,23 +27,18 @@ export default class IndexPage extends Component {
this.lastDiscussion = app.current.discussion; this.lastDiscussion = app.current.discussion;
} }
const params = this.params(); // If the user is coming from the discussion list, then they have either
// just switched one of the parameters (filter, sort, search) or they
if (app.cache.discussionList) { // probably want to refresh the results. We will clear the discussion list
// Compare the requested parameters (sort, search query) to the ones that // cache so that results are reloaded.
// are currently present in the cached discussion list. If they differ, we if (app.current instanceof IndexPage) {
// will clear the cache and set up a new discussion list component with app.cache.discussionList = null;
// the new parameters.
Object.keys(params).some(key => {
if (app.cache.discussionList.props.params[key] !== params[key]) {
app.cache.discussionList = null;
return true;
}
});
} }
if (!app.cache.discussionList) { if (!app.cache.discussionList) {
app.cache.discussionList = new DiscussionList({params}); app.cache.discussionList = new DiscussionList({
params: this.params()
});
} }
app.history.push('index'); app.history.push('index');

View File

@ -47,7 +47,6 @@ export default function boot(app) {
if (e.ctrlKey || e.metaKey || e.which === 2) return; if (e.ctrlKey || e.metaKey || e.which === 2) return;
e.preventDefault(); e.preventDefault();
app.history.home(); app.history.home();
app.drawer.hide();
}); });
// Add a class to the body which indicates that the page has been scrolled // Add a class to the body which indicates that the page has been scrolled