feat: invalidate moderation thread upon submit project redirect

This commit is contained in:
tdgao
2026-09-04 14:10:38 -06:00
parent 3427ed20d2
commit 44ffcf5a37
+13 -3
View File
@@ -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() },
) )
} }