Changeset View
Changeset View
Standalone View
Standalone View
lib/selectors/chat-selectors.js
Show First 20 Lines • Show All 361 Lines • ▼ Show 20 Lines | if (messageInfo.action === 'add_reaction') { | ||||
messageInfo.creator.id, | messageInfo.creator.id, | ||||
messageInfo.creator, | messageInfo.creator, | ||||
); | ); | ||||
} else { | } else { | ||||
messageReactionUsersInfoMap.delete(messageInfo.creator.id); | messageReactionUsersInfoMap.delete(messageInfo.creator.id); | ||||
} | } | ||||
} | } | ||||
const targetMessageEditMap = new Map<string, string>(); | |||||
for (let i = messages.length - 1; i >= 0; i--) { | |||||
const messageInfo = messages[i]; | |||||
if (messageInfo.type !== messageTypes.EDIT_MESSAGE) { | |||||
continue; | |||||
} | |||||
targetMessageEditMap.set(messageInfo.targetMessageID, messageInfo.text); | |||||
} | |||||
const chatMessageItems = []; | const chatMessageItems = []; | ||||
let lastMessageInfo = null; | let lastMessageInfo = null; | ||||
for (let i = messages.length - 1; i >= 0; i--) { | for (let i = messages.length - 1; i >= 0; i--) { | ||||
const messageInfo = messages[i]; | const messageInfo = messages[i]; | ||||
if ( | if ( | ||||
messageInfo.type === messageTypes.REACTION || | messageInfo.type === messageTypes.REACTION || | ||||
messageInfo.type === messageTypes.EDIT_MESSAGE | messageInfo.type === messageTypes.EDIT_MESSAGE | ||||
) { | ) { | ||||
continue; | continue; | ||||
} | } | ||||
const originalMessageInfo = | let originalMessageInfo = | ||||
messageInfo.type === messageTypes.SIDEBAR_SOURCE | messageInfo.type === messageTypes.SIDEBAR_SOURCE | ||||
? messageInfo.sourceMessage | ? messageInfo.sourceMessage | ||||
: messageInfo; | : messageInfo; | ||||
if (isEmptyMediaMessage(originalMessageInfo)) { | if (isEmptyMediaMessage(originalMessageInfo)) { | ||||
continue; | continue; | ||||
} | } | ||||
if ( | |||||
originalMessageInfo.type === messageTypes.TEXT && | |||||
originalMessageInfo.id | |||||
) { | |||||
const newText = targetMessageEditMap.get(originalMessageInfo.id); | |||||
if (newText !== undefined) { | |||||
ginsu: Could we simply this condition to this? Or are we concerned about `newText` possibly being an… | |||||
kubaAuthorUnsubmitted Done Inline ActionsI changed it, but then after more thought, I believe, that it should stay like this. If the newText is empty we would prefer to display an even empty message, than the original content (that is what the user would probably want). I revert the changes. We can consider preventing users from sending empty edit messages. But in the future, it would be easy to add deleting messages by sending edit messages with empty text. We would just not display them at all. kuba: I changed it, but then after more thought, I believe, that it should stay like this. If the… | |||||
originalMessageInfo = { ...originalMessageInfo, text: newText }; | |||||
} | |||||
} | |||||
let startsConversation = true; | let startsConversation = true; | ||||
let startsCluster = true; | let startsCluster = true; | ||||
if ( | if ( | ||||
lastMessageInfo && | lastMessageInfo && | ||||
lastMessageInfo.time + msInFiveMinutes > originalMessageInfo.time | lastMessageInfo.time + msInFiveMinutes > originalMessageInfo.time | ||||
) { | ) { | ||||
startsConversation = false; | startsConversation = false; | ||||
if ( | if ( | ||||
▲ Show 20 Lines • Show All 216 Lines • Show Last 20 Lines |
Could we simply this condition to this? Or are we concerned about newText possibly being an empty string?