Page MenuHomePhabricator

D7175.id24288.diff
No OneTemporary

D7175.id24288.diff

diff --git a/lib/selectors/chat-selectors.js b/lib/selectors/chat-selectors.js
--- a/lib/selectors/chat-selectors.js
+++ b/lib/selectors/chat-selectors.js
@@ -291,6 +291,7 @@
endsCluster: boolean,
+threadCreatedFromMessage: ?ThreadInfo,
+reactions: ReactionInfo,
+ +isPinned: boolean,
};
export type ChatMessageItem = { itemType: 'loader' } | ChatMessageInfoItem;
@@ -367,6 +368,24 @@
}
}
+ const targetMessagePinStatusMap = new Map<string, boolean>();
+ // Once again, we iterate backwards to put the order of messages in
+ // chronological order (i.e. oldest to newest) to handle pinned messages.
+ // This is important because we want to make sure that the most recent pin
+ // action is the one that is used to determine whether a message
+ // is pinned or not.
+ for (let i = messages.length - 1; i >= 0; i--) {
+ const messageInfo = messages[i];
+ if (messageInfo.type !== messageTypes.TOGGLE_PIN) {
+ continue;
+ }
+
+ targetMessagePinStatusMap.set(
+ messageInfo.targetMessageID,
+ messageInfo.action === 'pin',
+ );
+ }
+
const chatMessageItems = [];
let lastMessageInfo = null;
for (let i = messages.length - 1; i >= 0; i--) {
@@ -410,6 +429,11 @@
? threadInfoFromSourceMessageID[messageInfo.id]
: undefined;
+ const isPinned = !!(
+ originalMessageInfo.id &&
+ targetMessagePinStatusMap.get(originalMessageInfo.id)
+ );
+
const renderedReactions: ReactionInfo = (() => {
const result = {};
@@ -467,6 +491,7 @@
endsCluster: false,
threadCreatedFromMessage,
reactions: renderedReactions,
+ isPinned,
});
} else {
invariant(

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 2:51 AM (21 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578095
Default Alt Text
D7175.id24288.diff (1 KB)

Event Timeline