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 // Copyright 2021-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only // SPDX-License-Identifier: AGPL-3.0-only
import { import { identity, isEqual, isNumber, isObject, map, omit, pick } from 'lodash';
identity,
isEqual,
isNumber,
isObject,
map,
omit,
pick,
reduce,
} from 'lodash';
import { createSelectorCreator } from 'reselect'; import { createSelectorCreator } from 'reselect';
import filesize from 'filesize'; import filesize from 'filesize';
@ -506,7 +497,7 @@ export const getPropsForQuote = createSelectorCreator(memoizeByRoot, isEqual)(
id: sentAt, id: sentAt,
isViewOnce, isViewOnce,
referencedMessageNotFound, referencedMessageNotFound,
text, text = '',
} = quote; } = quote;
const contact = conversationSelector(authorUuid || author); const contact = conversationSelector(authorUuid || author);
@ -540,7 +531,7 @@ export const getPropsForQuote = createSelectorCreator(memoizeByRoot, isEqual)(
isViewOnce, isViewOnce,
referencedMessageNotFound, referencedMessageNotFound,
sentAt: Number(sentAt), sentAt: Number(sentAt),
text: createNonBreakingLastSeparator(text), text,
}; };
}, },
@ -676,7 +667,7 @@ const getShallowPropsForMessage = createSelectorCreator(memoizeByRoot, isEqual)(
readStatus: message.readStatus ?? ReadStatus.Read, readStatus: message.readStatus ?? ReadStatus.Read,
selectedReaction, selectedReaction,
status: getMessagePropStatus(message, ourConversationId), status: getMessagePropStatus(message, ourConversationId),
text: createNonBreakingLastSeparator(message.body), text: message.body,
textPending: message.bodyPending, textPending: message.bodyPending,
timestamp: message.sent_at, timestamp: message.sent_at,
}; };
@ -1331,22 +1322,6 @@ export function isTapToView(message: MessageWithUIFieldsType): boolean {
return Boolean(message.isViewOnce || message.messageTimer); 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( export function getMessagePropStatus(
message: Pick< message: Pick<
MessageWithUIFieldsType, MessageWithUIFieldsType,