feat: not return to post list after publishing

This commit is contained in:
DIYgod 2023-01-17 19:10:47 +00:00
parent 5d5bb98fa3
commit 6a2fbd1df4
No known key found for this signature in database
2 changed files with 14 additions and 4 deletions

View File

@ -81,7 +81,7 @@ export default function SubdomainEditor() {
page.data ? getPageVisibility(page.data) : PageVisibilityEnum.Draft,
)
}
}, [page.isSuccess])
}, [page.isSuccess, page.data])
const uploadFile = useUploadFile()
@ -171,9 +171,19 @@ export default function SubdomainEditor() {
if (draftKey) {
delStorage(draftKey)
queryClient.invalidateQueries(["getPagesBySite", subdomain])
queryClient.invalidateQueries(["getPage", draftKey])
queryClient.invalidateQueries([
"getPage",
draftKey.replace(`draft-${subdomain}-`, ""),
])
} else {
queryClient.invalidateQueries(["getPage", pageId])
}
if (createOrUpdatePage.data.data) {
router.replace(
`/dashboard/${subdomain}/editor?id=${site.data?.metadata?.proof}-${createOrUpdatePage.data.data}&type=${router.query.type}`,
)
}
router.push(`/dashboard/${subdomain}/${isPost ? "posts" : "pages"}`)
} else {
toast.error("Error: " + createOrUpdatePage.data?.message)
}

View File

@ -59,7 +59,7 @@ export const useGetPagesBySite = (
export const useGetPage = (input: Parameters<typeof pageModel.getPage>[0]) => {
const unidata = useUnidata()
return useQuery(["getPage", input.page, input], async () => {
return useQuery(["getPage", input.page || input.pageId, input], async () => {
if (!input.site || !(input.page || input.pageId)) {
return null
}