Партии: оптимистичная блокировка (version) — устаревшие правки/отмена отклоняются (фикс гонки завершить-vs-отменить)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-17 22:39:20 +03:00
co-authored by Claude Opus 4.8
parent eb34714868
commit 16452f7bbe
8 changed files with 148 additions and 13 deletions
+6 -2
View File
@@ -70,10 +70,14 @@ export function useFinishMatch() {
export function useDeleteMatch() {
const qc = useQueryClient();
return useMutation({
mutationFn: async (matchId: number) =>
// expectedVersion — оптимистичная блокировка: отмена устаревшей версии вернёт 409 STALE_WRITE.
mutationFn: async (args: { matchId: number; expectedVersion?: string }) =>
unwrap(
await api.DELETE("/api/matches/{match_id}", {
params: { path: { match_id: matchId } },
params: {
path: { match_id: args.matchId },
query: args.expectedVersion ? { expected_version: args.expectedVersion } : {},
},
}),
),
onSuccess: () => qc.invalidateQueries(),