mirror of
https://github.com/modrinth/code.git
synced 2026-09-05 06:19:11 +00:00
feat: invalidate moderation thread upon submit project redirect
This commit is contained in:
@@ -1454,8 +1454,8 @@ const patchProjectMutation = useMutation({
|
|||||||
|
|
||||||
// Mutation for changing project status (setProcessing)
|
// Mutation for changing project status (setProcessing)
|
||||||
const patchStatusMutation = useMutation({
|
const patchStatusMutation = useMutation({
|
||||||
mutationFn: async ({ projectId, status }) => {
|
mutationFn: async (variables) => {
|
||||||
await client.labrinth.projects_v2.edit(projectId, { status })
|
await client.labrinth.projects_v2.edit(variables.projectId, { status: variables.status })
|
||||||
},
|
},
|
||||||
|
|
||||||
onMutate: async ({ projectId, status }) => {
|
onMutate: async ({ projectId, status }) => {
|
||||||
@@ -1471,6 +1471,12 @@ const patchStatusMutation = useMutation({
|
|||||||
return { previousProject, projectId }
|
return { previousProject, projectId }
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onSuccess: async (_data, { threadId }) => {
|
||||||
|
if (threadId) {
|
||||||
|
await queryClient.invalidateQueries({ queryKey: ['thread', threadId] })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
onError: (err, _variables, context) => {
|
onError: (err, _variables, context) => {
|
||||||
if (context?.previousProject) {
|
if (context?.previousProject) {
|
||||||
queryClient.setQueryData(['project', 'v2', context.projectId], context.previousProject)
|
queryClient.setQueryData(['project', 'v2', context.projectId], context.previousProject)
|
||||||
@@ -2161,7 +2167,11 @@ async function setProcessing() {
|
|||||||
|
|
||||||
startLoading()
|
startLoading()
|
||||||
patchStatusMutation.mutate(
|
patchStatusMutation.mutate(
|
||||||
{ projectId: project.value.id, status: 'processing' },
|
{
|
||||||
|
projectId: project.value.id,
|
||||||
|
status: 'processing',
|
||||||
|
threadId: project.value.thread_id,
|
||||||
|
},
|
||||||
{ onSettled: () => stopLoading() },
|
{ onSettled: () => stopLoading() },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user