Make sure discussion list is refreshed if it needs to be

This commit is contained in:
Toby Zerner 2015-07-28 21:24:38 +09:30
parent 6a57ff8b51
commit 42d02569ac

View File

@ -35,12 +35,25 @@ export default class IndexPage extends Component {
app.cache.discussionList = null;
}
if (!app.cache.discussionList) {
app.cache.discussionList = new DiscussionList({
params: this.params()
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 (!app.cache.discussionList) {
app.cache.discussionList = new DiscussionList({params});
}
app.history.push('index');
app.current = this;
app.drawer.hide();