Skip to content

Commit

Permalink
Filter out duplicate messages
Browse files Browse the repository at this point in the history
  • Loading branch information
gdbroman committed Apr 4, 2023
1 parent decda33 commit d2d736a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/src/renderer/apps/Courier/views/ChatLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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 (
<Box
key={row.id}
mx="1px"
pt={topSpacing}
pb={isLast ? bottomSpacing : 0}
Expand Down

0 comments on commit d2d736a

Please sign in to comment.