Add cache invalidation to all project/round mutations platform-wide
Mutations for create, update, delete, import, filtering finalize, override, and reinstate now properly invalidate related queries so the UI updates without requiring a page refresh. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -39,6 +39,7 @@ export default function FilteringDashboardPage({
|
||||
trpc.filtering.getResultStats.useQuery({ roundId })
|
||||
const { data: rules } = trpc.filtering.getRules.useQuery({ roundId })
|
||||
|
||||
const utils = trpc.useUtils()
|
||||
const executeRules = trpc.filtering.executeRules.useMutation()
|
||||
const finalizeResults = trpc.filtering.finalizeResults.useMutation()
|
||||
|
||||
@@ -63,6 +64,8 @@ export default function FilteringDashboardPage({
|
||||
`Finalized: ${result.passed} passed, ${result.filteredOut} filtered out`
|
||||
)
|
||||
refetchStats()
|
||||
utils.project.list.invalidate()
|
||||
utils.round.get.invalidate({ id: roundId })
|
||||
} catch (error) {
|
||||
toast.error(
|
||||
error instanceof Error ? error.message : 'Failed to finalize'
|
||||
|
||||
@@ -105,6 +105,7 @@ export default function FilteringResultsPage({
|
||||
perPage,
|
||||
})
|
||||
|
||||
const utils = trpc.useUtils()
|
||||
const overrideResult = trpc.filtering.overrideResult.useMutation()
|
||||
const reinstateProject = trpc.filtering.reinstateProject.useMutation()
|
||||
|
||||
@@ -127,6 +128,7 @@ export default function FilteringResultsPage({
|
||||
setOverrideDialog(null)
|
||||
setOverrideReason('')
|
||||
refetch()
|
||||
utils.project.list.invalidate()
|
||||
} catch {
|
||||
toast.error('Failed to override result')
|
||||
}
|
||||
@@ -137,6 +139,7 @@ export default function FilteringResultsPage({
|
||||
await reinstateProject.mutateAsync({ roundId, projectId })
|
||||
toast.success('Project reinstated')
|
||||
refetch()
|
||||
utils.project.list.invalidate()
|
||||
} catch {
|
||||
toast.error('Failed to reinstate project')
|
||||
}
|
||||
|
||||
@@ -76,6 +76,8 @@ function RoundDetailContent({ roundId }: { roundId: string }) {
|
||||
const deleteRound = trpc.round.delete.useMutation({
|
||||
onSuccess: () => {
|
||||
toast.success('Round deleted')
|
||||
utils.program.list.invalidate()
|
||||
utils.round.list.invalidate()
|
||||
router.push('/admin/rounds')
|
||||
},
|
||||
onError: () => {
|
||||
|
||||
Reference in New Issue
Block a user