diff --git a/packages/livechat/src/lib/main.js b/packages/livechat/src/lib/main.js index 413243505890..4f985c33113f 100644 --- a/packages/livechat/src/lib/main.js +++ b/packages/livechat/src/lib/main.js @@ -83,7 +83,7 @@ export const getLastReadMessage = () => { : renderedMessages .slice() .reverse() - .find((item) => item.u._id === user._id); + .find((item) => item.u._id === user?._id); }; export const getUnreadMessages = () => { @@ -95,7 +95,7 @@ export const getUnreadMessages = () => { : renderedMessages .slice() .reverse() - .findIndex((item) => item.u._id === user._id); + .findIndex((item) => item.u._id === user?._id); if (lastReadMessageIndex !== -1) { const unreadMessages = renderedMessages.slice(lastReadMessageIndex + 1).filter((message) => message.u._id !== user._id);