add related stories to pre-fetch caching.
This commit is contained in:
parent
c1b6349771
commit
25caee17d6
|
@ -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 => { }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user