mirror of
https://github.com/modrinth/code.git
synced 2026-09-04 22:10:15 +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)
|
||||
const patchStatusMutation = useMutation({
|
||||
mutationFn: async ({ projectId, status }) => {
|
||||
await client.labrinth.projects_v2.edit(projectId, { status })
|
||||
mutationFn: async (variables) => {
|
||||
await client.labrinth.projects_v2.edit(variables.projectId, { status: variables.status })
|
||||
},
|
||||
|
||||
onMutate: async ({ projectId, status }) => {
|
||||
@@ -1471,6 +1471,12 @@ const patchStatusMutation = useMutation({
|
||||
return { previousProject, projectId }
|
||||
},
|
||||
|
||||
onSuccess: async (_data, { threadId }) => {
|
||||
if (threadId) {
|
||||
await queryClient.invalidateQueries({ queryKey: ['thread', threadId] })
|
||||
}
|
||||
},
|
||||
|
||||
onError: (err, _variables, context) => {
|
||||
if (context?.previousProject) {
|
||||
queryClient.setQueryData(['project', 'v2', context.projectId], context.previousProject)
|
||||
@@ -2161,7 +2167,11 @@ async function setProcessing() {
|
||||
|
||||
startLoading()
|
||||
patchStatusMutation.mutate(
|
||||
{ projectId: project.value.id, status: 'processing' },
|
||||
{
|
||||
projectId: project.value.id,
|
||||
status: 'processing',
|
||||
threadId: project.value.thread_id,
|
||||
},
|
||||
{ onSettled: () => stopLoading() },
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user