Skip to content

Commit

Permalink
fix: fix resend message not work as expected when followed by an erro…
Browse files Browse the repository at this point in the history
…r message
  • Loading branch information
lisiur committed Apr 14, 2023
1 parent 49ab6f7 commit 292dcb2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion web/src/models/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,15 @@ export class Chat {

const userMessage = this.messages[index] as UserMessage;

if (index === this.messages.length - 1) {
if (
index === this.messages.length - 1 ||
(index === this.messages.length - 2 &&
this.messages[index + 1] instanceof ErrorMessage)
) {
// We can reuse the message if it is the last message
// or is the second last message and the last message is an error message

this.messages.length = index + 1;

userMessage.delivered = false;
userMessage.finished = null;
Expand Down

0 comments on commit 292dcb2

Please sign in to comment.