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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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