diff --git a/src/utils.ts b/src/utils.ts index c3bd41464..af763cc3a 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -384,8 +384,10 @@ export function addToMessageList( } // for empty list just concat and return unless it's an update or deletion - if (!newMessages.length && addMessageToList) { + if (newMessages.length === 0 && addMessageToList) { return newMessages.concat(newMessage); + } else if (newMessages.length === 0) { + return newMessages; } // eslint-disable-next-line @typescript-eslint/no-non-null-assertion @@ -396,6 +398,8 @@ export function addToMessageList( // if message is newer than last item in the list concat and return unless it's an update or deletion if (messageIsNewest && addMessageToList) { return newMessages.concat(newMessage); + } else if (newMessages.length === 0) { + return newMessages; } // find the closest index to push the new message