Skip to content

Commit

Permalink
Refetch using manual visibility change
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Jul 9, 2024
1 parent 53eb6d3 commit 972b7e3
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/modules/chat/HomePage/ChatContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,21 @@ function PostMemeButton({

const myAddress = useMyMainAddress() ?? ''
const { data, isLoading } = getBalanceQuery.useQuery(myAddress)
const { data: timeLeftFromApi, isLoading: loadingTimeLeft } =
getTimeLeftUntilCanPostQuery.useQuery(myAddress, {
refetchOnWindowFocus: true,
staleTime: 0,
})

const {
data: timeLeftFromApi,
isLoading: loadingTimeLeft,
refetch,
} = getTimeLeftUntilCanPostQuery.useQuery(myAddress)
useEffect(() => {
const listener = () => {
if (document.visibilityState === 'visible') refetch()
}
document.addEventListener('visibilitychange', listener, false)
return () => {
document.removeEventListener('visibilitychange', listener)
}
}, [refetch])

const { threshold, isLoading: loadingThreshold } =
usePostMemeThreshold(chatId)
Expand Down

0 comments on commit 972b7e3

Please sign in to comment.