feat(queries/page): update `useMintPage` hooks
This commit is contained in:
parent
3d0a9da7a4
commit
101c5b36b8
|
|
@ -79,10 +79,7 @@ export const Reactions: React.FC<{
|
|||
if (isMint.data?.count) {
|
||||
setIsMintOpen(true)
|
||||
} else {
|
||||
mintPage.mutate({
|
||||
address,
|
||||
pageId: pageId,
|
||||
})
|
||||
mintPage.mutate(parsePageId(pageId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -99,10 +96,7 @@ export const Reactions: React.FC<{
|
|||
router.push(`${SITE_URL}/dashboard/new-site`)
|
||||
}
|
||||
if (!isMint.data.count) {
|
||||
mintPage.mutate({
|
||||
address,
|
||||
pageId: pageId,
|
||||
})
|
||||
mintPage.mutate(parsePageId(pageId))
|
||||
}
|
||||
setMintProgress(false)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,12 @@ import {
|
|||
usePostNoteForNote,
|
||||
useLikeNote,
|
||||
useUnlikeNote,
|
||||
useMintNote,
|
||||
} from "@crossbell/connect-kit"
|
||||
import { useContract } from "@crossbell/contract"
|
||||
import { useRefCallback } from "@crossbell/util-hooks"
|
||||
|
||||
import * as pageModel from "~/models/page.model"
|
||||
|
||||
import { useUnidata } from "./unidata"
|
||||
|
||||
export const useGetPagesBySiteLite = (
|
||||
|
|
@ -203,23 +204,19 @@ export function useUnlikePage() {
|
|||
}
|
||||
|
||||
export function useMintPage() {
|
||||
const contract = useContract()
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation(
|
||||
async (input: Parameters<typeof pageModel.mintPage>[0]) => {
|
||||
return pageModel.mintPage(input, contract)
|
||||
const address = useAccountState((s) => s.wallet?.address)
|
||||
|
||||
return useMintNote({
|
||||
onSuccess: (_, variables) => {
|
||||
const pageId = pageModel.toPageId(variables)
|
||||
|
||||
return Promise.all([
|
||||
queryClient.invalidateQueries(["checkMint", pageId, address]),
|
||||
queryClient.invalidateQueries(["getMints", pageId]),
|
||||
])
|
||||
},
|
||||
{
|
||||
onSuccess: (data, variables) => {
|
||||
queryClient.invalidateQueries([
|
||||
"checkMint",
|
||||
variables.pageId,
|
||||
variables.address,
|
||||
])
|
||||
queryClient.invalidateQueries(["getMints", variables.pageId])
|
||||
},
|
||||
},
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
export function useCommentPage() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue