Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3357850
D7175.id24852.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D7175.id24852.diff
View Options
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
@@ -292,6 +292,7 @@
+threadCreatedFromMessage: ?ThreadInfo,
+reactions: ReactionInfo,
+hasBeenEdited: boolean,
+ +isPinned: boolean,
};
export type ChatMessageItem = { itemType: 'loader' } | ChatMessageInfoItem;
@@ -377,6 +378,24 @@
targetMessageEditMap.set(messageInfo.targetMessageID, messageInfo.text);
}
+ 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--) {
@@ -438,6 +457,11 @@
? threadInfoFromSourceMessageID[messageInfo.id]
: undefined;
+ const isPinned = !!(
+ originalMessageInfo.id &&
+ targetMessagePinStatusMap.get(originalMessageInfo.id)
+ );
+
const renderedReactions: ReactionInfo = (() => {
const result = {};
@@ -496,6 +520,7 @@
threadCreatedFromMessage,
reactions: renderedReactions,
hasBeenEdited,
+ isPinned,
});
} else {
invariant(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 1:57 AM (20 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2577906
Default Alt Text
D7175.id24852.diff (1 KB)
Attached To
Mode
D7175: [lib] Include an isPinned flag in ChatMessageInfoItem
Attached
Detach File
Event Timeline
Log In to Comment