Skip to content

Commit

Permalink
fix: updating robust timeout refetch fn
Browse files Browse the repository at this point in the history
  • Loading branch information
TurtIeSocks committed Jan 12, 2024
1 parent 8895edd commit ff84870
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/QueryData.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,13 @@ function QueryData({ category, timeout }) {
if (active) {
timeout.current.setupTimeout(refetch)
return () => {
useMemory.setState({ excludeList: [] })
useMemory.setState((prev) => ({
excludeList: prev.excludeList.length ? [] : prev.excludeList,
}))
timeout.current.off()
}
}
}, [active, refetch, timeout])
}, [active, refetch, timeout.current])

React.useEffect(() => {
const refetchData = () => {
Expand All @@ -161,7 +163,7 @@ function QueryData({ category, timeout }) {
return () => {
map.off('fetchdata', refetchData)
}
}, [filters, userSettings, onlyAreas])
}, [filters, userSettings, onlyAreas, timeout.current.refetch])

if (error) {
// @ts-ignore
Expand Down
2 changes: 2 additions & 0 deletions src/services/apollo/RobustTimeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,7 @@ export default class RobustTimeout extends AbortableContext {

off() {
clearTimeout(this.timeout)
this.refetch = null
delete this._pendingVariables
}
}

0 comments on commit ff84870

Please sign in to comment.