-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(playstreak-sync): add sync button logic (#22)
* feat(playstreak-sync): add sync button logic * chore: set correct pkg version * chore: update lock * chore: prettier
- Loading branch information
1 parent
648cf4c
commit b90372c
Showing
6 changed files
with
366 additions
and
228 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useQueryClient, useQuery } from '@tanstack/react-query' | ||
import { useAccount } from 'wagmi' | ||
|
||
export function useHasPendingExternalSync({ | ||
questId, | ||
getPendingExternalSync | ||
}: { | ||
questId: number | null | ||
getPendingExternalSync: (questId: number) => Promise<boolean> | ||
}) { | ||
const { address } = useAccount() | ||
const queryClient = useQueryClient() | ||
const queryKey = ['pending-external-sync', questId, address] | ||
const query = useQuery({ | ||
queryKey, | ||
queryFn: async () => { | ||
if (!questId) { | ||
return false | ||
} | ||
return getPendingExternalSync(questId) | ||
}, | ||
enabled: questId !== undefined | ||
}) | ||
|
||
return { | ||
...query, | ||
invalidateQuery: async () => queryClient.invalidateQueries({ queryKey }) | ||
} | ||
} |