Merge commit '77a592a05c9e599c3dcedb59c1fadc70699bd2e6' into background-task

This commit is contained in:
Peter
2019-10-22 19:10:24 +04:00
97 changed files with 1504 additions and 1090 deletions

View File

@@ -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
}