Fix error in <ConversationListItem>

This commit is contained in:
Evan Hahn 2021-09-07 15:38:37 -05:00 committed by GitHub
parent 7f34bedd87
commit 634f4a8bb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -198,6 +198,12 @@ export const ConversationListItem: FunctionComponent<Props> = React.memo(
}
);
function truncateMessageText(text: undefined | string = ''): string {
// This takes `unknown` because, sometimes, values from the database don't match our
// types. In the long term, we should fix that. In the short term, this smooths over the
// problem.
function truncateMessageText(text: unknown): string {
if (typeof text !== 'string') {
return '';
}
return text.split('\n', 1)[0];
}