Skip to content

Commit

Permalink
fix: checking for index of of current message instead of checking for…
Browse files Browse the repository at this point in the history
… user messages amount
  • Loading branch information
alashchev17 committed Jan 28, 2025
1 parent c002c2f commit fc2291b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/hooks/useCheckpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const useCheckpoints = () => {
async (checkpoints: Checkpoint[] | null, messageIndex: number) => {
if (!checkpoints) return;
const amountOfUserMessages = messages.filter(isUserMessage);
const firstUserMessage = amountOfUserMessages[0];

const restoredChanges =
await restoreChangesFromCheckpoints(checkpoints).unwrap();
Expand All @@ -88,7 +89,9 @@ export const useCheckpoints = () => {
dispatch(setIsUndoingCheckpoints(false)),
setLatestCheckpointResult({ ...restoredChanges, messageIndex }),
setIsCheckpointsPopupIsVisible(true),
setShouldNewChatBeStarted(amountOfUserMessages.length === 1),
setShouldNewChatBeStarted(
messageIndex === messages.indexOf(firstUserMessage),
),
];
actions.forEach((action) => dispatch(action));
},
Expand Down

0 comments on commit fc2291b

Please sign in to comment.