Skip to content

Commit 80f3e85

Browse files
committed
fix(app): Set useSearchResults nextFetchPolicy to cache-and-network to prevent supressing loading state on refetch
1 parent 6c92fb4 commit 80f3e85

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

packages/openneuro-app/src/scripts/search/search-container.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,6 @@ const SearchContainer: FC<SearchContainerProps> = ({ portalContent }) => {
120120
const is_grant_portal = portalContent?.portal || false
121121
const grant = portalContent?.grant || null
122122

123-
const [initialLoading, setInitialLoading] = useState(true)
124-
125123
useEffect(() => {
126124
setDefaultSearch(
127125
modality,
@@ -142,12 +140,6 @@ const SearchContainer: FC<SearchContainerProps> = ({ portalContent }) => {
142140

143141
const { loading, data, fetchMore, variables } = useSearchResults()
144142

145-
useEffect(() => {
146-
if (!loading && data) {
147-
setInitialLoading(false)
148-
}
149-
}, [loading, data])
150-
151143
const loadMore = () => {
152144
fetchMore({
153145
variables: {
@@ -285,7 +277,7 @@ const SearchContainer: FC<SearchContainerProps> = ({ portalContent }) => {
285277
</>
286278
)}
287279
renderLoading={() =>
288-
(initialLoading || loading)
280+
loading
289281
? (
290282
<div className="search-loading">
291283
<Loading />

packages/openneuro-app/src/scripts/search/use-search-results.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ export const useSearchResults = () => {
404404
// fetchPolicy is workaround for stuck loading bug (https://github.com/apollographql/react-apollo/issues/3270#issuecomment-579614837)
405405
// TODO: find better solution
406406
fetchPolicy: "cache-and-network",
407-
nextFetchPolicy: "cache-first",
407+
nextFetchPolicy: "cache-and-network",
408408
notifyOnNetworkStatusChange: true,
409409
})
410410
}

0 commit comments

Comments
 (0)