From 25caee17d63e704db61a6e4b057ba2ffb53228a1 Mon Sep 17 00:00:00 2001 From: Jason Schwarzenberger Date: Mon, 23 Nov 2020 16:26:37 +1300 Subject: [PATCH] add related stories to pre-fetch caching. --- webclient/src/pages/Feed.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/webclient/src/pages/Feed.js b/webclient/src/pages/Feed.js index 0011093..213b00f 100644 --- a/webclient/src/pages/Feed.js +++ b/webclient/src/pages/Feed.js @@ -30,10 +30,13 @@ class Feed extends React.Component { stories.forEach((x, i) => { fetch('/api/' + x.id) .then(res => res.json()) - .then(({ story }) => { - localForage.setItem(x.id, story) - .then(console.log('preloaded', x.id, x.title)); + .then(({ story, related }) => { + Promise.all([ + 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(`related-${x.id}`, related); }, error => { } ); });