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 7a67d3ab95
commit f07ab4633b
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;
}
const params = this.params();
if (app.cache.discussionList) {
// Compare the requested parameters (sort, search query) to the ones that
// are currently present in the cached discussion list. If they differ, we
// will clear the cache and set up a new discussion list component with
// the new parameters.
Object.keys(params).some(key => {
if (app.cache.discussionList.props.params[key] !== params[key]) {
app.cache.discussionList = null;
return true;
}
});
// 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) {
app.cache.discussionList = null;
}
if (!app.cache.discussionList) {
app.cache.discussionList = new DiscussionList({params});
app.cache.discussionList = new DiscussionList({
params: this.params()
});
}
app.history.push('index');

View File

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