Skip to content

Commit

Permalink
Fix reprocess history
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbuddy committed Mar 30, 2024
1 parent 62dd1c2 commit 4a93132
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions internal/site/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -511,13 +511,13 @@ function App() {
}
break;
case "reprocessHistoryResult":
if (evt.error) {
rejectGamePromise(evt.id, evt.error);
} else {
resolveGamePromise(evt.id, {initialState: evt.initialState, updates: evt.updates});
}
resolveGamePromise(evt.id, {
error: evt.error,
initialState: evt.initialState,
updates: evt.updates,
});
break;
case "updateSettings":
case "updateSettings":
if (!host) return;
setSettings(evt.settings);
setNumberAndSeat(evt.seatCount);
Expand Down Expand Up @@ -743,23 +743,25 @@ function App() {
}
setReprocessing(true);
const randomSeed = getRandomSeed();
const reprocessResult = await reprocessHistory({randomSeed, players, settings}, history.map(h => ({position: h.position, data: h.data})));
const reprocessResult = await reprocessHistory(
{ randomSeed, players, settings },
history.map((h) => ({ position: h.position, data: h.data }))
);

if (reprocessResult.error) {
toast.error(`Error from reprocessing: ${reprocessResult.error}`);
setReprocessing(false);
return
}

const newHistory = reprocessResult.updates.map((update, i) => ({
seq: i,
state: update,
data: history[i].data,
position: history[i].position,
}))
}));

setReprocessing(false);
setRandomSeed(randomSeed);
setInitialState({...initialState, state: reprocessResult.initialState});
setInitialState({ ...initialState, state: reprocessResult.initialState });
setHistory(newHistory);
setReprocessing(false);
}, [getRandomSeed, history, initialState, players, setRandomSeed, settings]);
Expand Down

0 comments on commit 4a93132

Please sign in to comment.