diff --git a/lib/shared/chat-message-item-utils.js b/lib/shared/chat-message-item-utils.js --- a/lib/shared/chat-message-item-utils.js +++ b/lib/shared/chat-message-item-utils.js @@ -40,6 +40,15 @@ return longAbsoluteDate(item.messageInfo.time); } +function chatMessageItemHasNonViewerMessage( + item: BaseChatMessageItem, + viewerID: ?string, +): boolean { + return ( + item.itemType === 'message' && item.messageInfo.creator.id !== viewerID + ); +} + type BaseChatMessageItemForEngagementCheck = { +threadCreatedFromMessage: ?ThreadInfo, +reactions: ReactionInfo, @@ -61,5 +70,6 @@ export { chatMessageItemKey, chatMessageInfoItemTimestamp, + chatMessageItemHasNonViewerMessage, chatMessageItemHasEngagement, }; diff --git a/native/chat/chat-list.react.js b/native/chat/chat-list.react.js --- a/native/chat/chat-list.react.js +++ b/native/chat/chat-list.react.js @@ -18,7 +18,10 @@ } from 'react-native'; import { FlatList } from 'react-native-gesture-handler'; -import { chatMessageItemKey } from 'lib/shared/chat-message-item-utils.js'; +import { + chatMessageItemKey, + chatMessageItemHasNonViewerMessage, +} from 'lib/shared/chat-message-item-utils.js'; import { localIDPrefix } from 'lib/shared/message-utils.js'; import type { ChatNavigationProp } from './chat.react.js'; @@ -144,6 +147,7 @@ } const { scrollPos } = this; + const { viewerID } = this.props; let curDataIndex = 0, prevDataIndex = 0, @@ -166,10 +170,7 @@ if (curItemKey.startsWith(localIDPrefix)) { newLocalMessage = true; - } else if ( - curItem.itemType === 'message' && - curItem.messageInfo.creator.id !== this.props.viewerID - ) { + } else if (chatMessageItemHasNonViewerMessage(curItem, viewerID)) { newRemoteMessageCount++; } adjustScrollPos += chatMessageItemHeight(curItem);