Bugfix/undo fix (#3)

* Add undoLink API function

* Call backend undo on undoLastLink to keep chain in sync
This commit is contained in:
2026-03-17 21:35:42 -07:00
committed by GitHub
parent f972de718c
commit d3e5428ced
2 changed files with 14 additions and 0 deletions
+4
View File
@@ -96,6 +96,10 @@ export async function validateLink(
return data;
}
export async function undoLink(gameId: string): Promise<void> {
await apiClient.post(`/games/${gameId}/undo`);
}
export async function getGameSession(id: string): Promise<GameHistoryEntry> {
const { data } = await apiClient.get<GameHistoryEntry>(`/games/${id}`);
return data;
+10
View File
@@ -261,6 +261,16 @@ export const useGameStore = create<GameState>((set, get) => ({
passedMovieB: hasPassedMovieB,
validationError: null,
});
// Fire-and-forget backend undo to keep DB chain in sync
const { sessionId } = get();
if (sessionId) {
import('@/api/games').then(({ undoLink }) => {
undoLink(sessionId).catch((err) => {
console.error('[GameStore] Failed to undo link on backend:', err);
});
});
}
},
setValidating: (isValidating: boolean) => set({ isValidating }),