mirror of
https://github.com/flarum/framework.git
synced 2024-12-12 14:13:37 +08:00
Add ability to refresh index page by clicking on logo. closes flarum/core#188
This commit is contained in:
parent
c5fd4418fb
commit
4f5e1d4aa3
|
@ -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');
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user