diff --git a/web/modals/chat/message-results-modal.react.js b/web/modals/chat/message-results-modal.react.js --- a/web/modals/chat/message-results-modal.react.js +++ b/web/modals/chat/message-results-modal.react.js @@ -72,8 +72,18 @@ return []; } + const pinnedMessageIDs = new Set(); + translatedMessageResults.forEach(item => pinnedMessageIDs.add(item.id)); + + // Some pinned messages not part of the Redux when a chat is loaded will + // get excluded since their `isPinned` flag will not be set as true. + // Adding the conditional clause to check if the chatMessageInfo's id + // is included in the set of pinned messages fetched from the DB will + // ensure we don't skip any pinned messages. const chatMessageInfoItems = chatMessageInfos.filter( - item => item.itemType === 'message' && item.isPinned, + item => + item.itemType === 'message' && + pinnedMessageIDs.has(item.messageInfo.id), ); // By the nature of using messageListData and passing in @@ -98,7 +108,7 @@ } return sortedChatMessageInfoItems; - }, [chatMessageInfos, rawMessageResults]); + }, [translatedMessageResults, chatMessageInfos, rawMessageResults]); const modifiedItems = React.useMemo( () =>