Skip to content

Commit dfa9ed0

Browse files
committed
Add cache-and-network and set loading
1 parent 2ab3a57 commit dfa9ed0

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/components/Section.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,39 +231,39 @@ const SectionWithData = ({ location: { state, pathname } }) => {
231231
if (state) {
232232
query = SECTION_BY_ID_QUERY
233233
variables = { id: state.section.id }
234-
createProps = ({ data, loading }) => ({
234+
createProps = ({ data }) => ({
235235
section: {
236236
...state.section,
237237
content: get(data, 'section.content'),
238238
views: get(data, 'section.views'),
239239
scrollY: get(data, 'section.scrollY')
240240
},
241241
chapter: state.chapter,
242-
loading
242+
loading: !data.section
243243
})
244244
} else if (page.chapterTitle) {
245245
query = SECTION_BY_CHAPTER_TITLE_QUERY
246246
variables = { title: page.chapterTitle }
247-
createProps = ({ data, loading }) => ({
247+
createProps = ({ data }) => ({
248248
section: get(data, 'chapterByTitle.section'),
249249
chapter: {
250250
...data.chapterByTitle,
251251
number: null
252252
},
253-
loading
253+
loading: !data.chapterByTitle
254254
})
255255
} else if (page.chapterNumber) {
256256
query = SECTION_BY_NUMBER_QUERY
257257
variables = page
258-
createProps = ({ data, loading }) => ({
258+
createProps = ({ data }) => ({
259259
section: get(data, 'chapterByNumber.section'),
260260
chapter: data.chapterByNumber,
261-
loading
261+
loading: !data.chapterByNumber
262262
})
263263
}
264264

265265
return (
266-
<Query query={query} variables={variables}>
266+
<Query query={query} variables={variables} fetchPolicy="cache-and-network">
267267
{queryInfo => (
268268
<Mutation mutation={VIEWED_SECTION_MUTATION}>
269269
{viewedSection => (

0 commit comments

Comments
 (0)