Speed up left pane message preview for long messages

This commit is contained in:
Evan Hahn
2021-08-27 15:49:45 -05:00
committed by GitHub
parent a43abe628a
commit ed11361b64

View File

@@ -130,7 +130,7 @@ export const ConversationListItem: FunctionComponent<Props> = React.memo(
{i18n('ConversationListItem--draft-prefix')} {i18n('ConversationListItem--draft-prefix')}
</span> </span>
<MessageBody <MessageBody
text={(draftPreview || '').split('\n')[0]} text={truncateMessageText(draftPreview)}
disableJumbomoji disableJumbomoji
disableLinks disableLinks
i18n={i18n} i18n={i18n}
@@ -144,7 +144,7 @@ export const ConversationListItem: FunctionComponent<Props> = React.memo(
</span> </span>
) : ( ) : (
<MessageBody <MessageBody
text={(messageBody || '').split('\n')[0]} text={truncateMessageText(messageBody)}
disableJumbomoji disableJumbomoji
disableLinks disableLinks
i18n={i18n} i18n={i18n}
@@ -197,3 +197,7 @@ export const ConversationListItem: FunctionComponent<Props> = React.memo(
); );
} }
); );
function truncateMessageText(text: undefined | string = ''): string {
return text.split('\n', 1)[0];
}