From bcbeab52c1fd4d0ceddae6858e6acece277b821e Mon Sep 17 00:00:00 2001 From: Qian Hong Date: Tue, 14 Feb 2023 12:45:40 +1100 Subject: [PATCH] fix: Remove createNonBreakingLastSeparator. Fix #2396. --- ts/models/message.ts | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/ts/models/message.ts b/ts/models/message.ts index 15e0ce5c2..15173a878 100644 --- a/ts/models/message.ts +++ b/ts/models/message.ts @@ -67,7 +67,6 @@ import _, { map, partition, pick, - reduce, reject, size as lodashSize, sortBy, @@ -474,7 +473,7 @@ export class MessageModel extends Backbone.Model { convoId: this.get('conversationId'), }; if (body) { - props.text = this.createNonBreakingLastSeparator(body); + props.text = body; } if (this.get('isDeleted')) { props.isDeleted = this.get('isDeleted'); @@ -534,16 +533,6 @@ export class MessageModel extends Backbone.Model { return props; } - public createNonBreakingLastSeparator(text: string) { - const nbsp = '\xa0'; - const regex = /(\S)( +)(\S+\s*)$/; - return text.replace(regex, (_match, start, spaces, end) => { - const newSpaces: any = - end.length < 12 ? reduce(spaces, accumulator => accumulator + nbsp, '') : spaces; - return `${start}${newSpaces}${end}`; - }); - } - public processQuoteAttachment(attachment: any) { const { thumbnail } = attachment; const path = thumbnail && thumbnail.path && getAbsoluteAttachmentPath(thumbnail.path); @@ -643,7 +632,7 @@ export class MessageModel extends Backbone.Model { if (quote.text) { // do not show text of not found messages. // if the message was deleted better not show it's text content in the message - quoteProps.text = this.createNonBreakingLastSeparator(sliceQuoteText(quote.text)); + quoteProps.text = sliceQuoteText(quote.text); } const quoteAttachment = firstAttachment