mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Merge commit '77a592a05c9e599c3dcedb59c1fadc70699bd2e6' into background-task
This commit is contained in:
@@ -825,31 +825,12 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
||||
}
|
||||
}
|
||||
|
||||
func foldLineBreaks(_ text: String, allowTwoLines: Bool) -> String {
|
||||
var lines = text.split { $0.isNewline }
|
||||
var startedBothLines = false
|
||||
var result = ""
|
||||
for line in lines {
|
||||
if result.isEmpty {
|
||||
result += line
|
||||
} else {
|
||||
if allowTwoLines && !startedBothLines {
|
||||
result += "\n" + line
|
||||
startedBothLines = true
|
||||
} else {
|
||||
result += " " + line
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
let messageText: String
|
||||
if let currentChatListText = currentChatListText, currentChatListText.0 == text {
|
||||
messageText = currentChatListText.1
|
||||
chatListText = currentChatListText
|
||||
} else {
|
||||
messageText = foldLineBreaks(text, allowTwoLines: peerText == nil)
|
||||
messageText = foldLineBreaks(text)
|
||||
chatListText = (text, messageText)
|
||||
}
|
||||
|
||||
@@ -857,7 +838,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
||||
hasDraft = true
|
||||
authorAttributedString = NSAttributedString(string: item.presentationData.strings.DialogList_Draft, font: textFont, textColor: theme.messageDraftTextColor)
|
||||
|
||||
attributedText = NSAttributedString(string: foldLineBreaks(embeddedState.text.string.replacingOccurrences(of: "\n\n", with: " "), allowTwoLines: false), font: textFont, textColor: theme.messageTextColor)
|
||||
attributedText = NSAttributedString(string: foldLineBreaks(embeddedState.text.string.replacingOccurrences(of: "\n\n", with: " ")), font: textFont, textColor: theme.messageTextColor)
|
||||
} else if let message = message {
|
||||
let composedString: NSMutableAttributedString
|
||||
if let inlineAuthorPrefix = inlineAuthorPrefix {
|
||||
@@ -1839,3 +1820,20 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func foldLineBreaks(_ text: String) -> String {
|
||||
var lines = text.split { $0.isNewline }
|
||||
var startedBothLines = false
|
||||
var result = ""
|
||||
for line in lines {
|
||||
if line.isEmpty {
|
||||
continue
|
||||
}
|
||||
if result.isEmpty {
|
||||
result += line
|
||||
} else {
|
||||
result += " " + line
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user