From d2d736adf7dd8a564b304e0479f2cf4cb2626726 Mon Sep 17 00:00:00 2001 From: gdbroman <99gustaf@gmail.com> Date: Tue, 4 Apr 2023 22:42:23 +0200 Subject: [PATCH] Filter out duplicate messages --- app/src/renderer/apps/Courier/views/ChatLog.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/renderer/apps/Courier/views/ChatLog.tsx b/app/src/renderer/apps/Courier/views/ChatLog.tsx index 37cc53191a..ae60c1d5ea 100644 --- a/app/src/renderer/apps/Courier/views/ChatLog.tsx +++ b/app/src/renderer/apps/Courier/views/ChatLog.tsx @@ -205,7 +205,13 @@ export const ChatLogPresenter = ({ storage }: ChatLogProps) => { height, width: containerWidth, }} - data={messages} + // Only unique message IDs are rendered + data={messages.filter( + (msg, i) => + i === 0 || + msg.id !== messages[i - 1].id || + msg.sender !== messages[i - 1].sender + )} initialTopMostItemIndex={messages.length - 1} followOutput="auto" itemContent={(index, row) => { @@ -230,10 +236,11 @@ export const ChatLogPresenter = ({ storage }: ChatLogProps) => { const prevMsgDate = messages[index - 1] && new Date(messages[index - 1].createdAt).toDateString(); - const showDate: boolean = - index === 0 || thisMsgDate !== prevMsgDate; + const showDate = index === 0 || thisMsgDate !== prevMsgDate; + return (