Remove createNonBreakingLastSeparator

This commit is contained in:
Fedor Indutny 2022-03-21 14:46:20 -07:00 committed by GitHub
parent 35b5087dc0
commit e08d9baaba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,16 +1,7 @@
// Copyright 2021-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import {
identity,
isEqual,
isNumber,
isObject,
map,
omit,
pick,
reduce,
} from 'lodash';
import { identity, isEqual, isNumber, isObject, map, omit, pick } from 'lodash';
import { createSelectorCreator } from 'reselect';
import filesize from 'filesize';
@ -506,7 +497,7 @@ export const getPropsForQuote = createSelectorCreator(memoizeByRoot, isEqual)(
id: sentAt,
isViewOnce,
referencedMessageNotFound,
text,
text = '',
} = quote;
const contact = conversationSelector(authorUuid || author);
@ -540,7 +531,7 @@ export const getPropsForQuote = createSelectorCreator(memoizeByRoot, isEqual)(
isViewOnce,
referencedMessageNotFound,
sentAt: Number(sentAt),
text: createNonBreakingLastSeparator(text),
text,
};
},
@ -676,7 +667,7 @@ const getShallowPropsForMessage = createSelectorCreator(memoizeByRoot, isEqual)(
readStatus: message.readStatus ?? ReadStatus.Read,
selectedReaction,
status: getMessagePropStatus(message, ourConversationId),
text: createNonBreakingLastSeparator(message.body),
text: message.body,
textPending: message.bodyPending,
timestamp: message.sent_at,
};
@ -1331,22 +1322,6 @@ export function isTapToView(message: MessageWithUIFieldsType): boolean {
return Boolean(message.isViewOnce || message.messageTimer);
}
function createNonBreakingLastSeparator(text?: string): string {
if (!text) {
return '';
}
const nbsp = '\xa0';
const regex = /(\S)( +)(\S+\s*)$/;
return text.replace(regex, (_match, start, spaces, end) => {
const newSpaces =
end.length < 12
? reduce(spaces, accumulator => accumulator + nbsp, '')
: spaces;
return `${start}${newSpaces}${end}`;
});
}
export function getMessagePropStatus(
message: Pick<
MessageWithUIFieldsType,