add related stories to pre-fetch caching.

This commit is contained in:
Jason Schwarzenberger 2020-11-23 16:26:37 +13:00
parent c1b6349771
commit 25caee17d6

View File

@ -30,10 +30,13 @@ class Feed extends React.Component {
stories.forEach((x, i) => { stories.forEach((x, i) => {
fetch('/api/' + x.id) fetch('/api/' + x.id)
.then(res => res.json()) .then(res => res.json())
.then(({ story }) => { .then(({ story, related }) => {
localForage.setItem(x.id, story) Promise.all([
.then(console.log('preloaded', x.id, x.title)); localForage.setItem(x.id, story),
localForage.setItem(`related-${x.id}`, related)
]).then(console.log('preloaded', x.id, x.title));
this.props.updateCache(x.id, story); this.props.updateCache(x.id, story);
this.props.updateCache(`related-${x.id}`, related);
}, error => { } }, error => { }
); );
}); });