From edbdcc2f0d7792d2fd080c71ce6aeb6bfdfca942 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 10 Sep 2023 02:25:57 +0400 Subject: [PATCH] Various fixes --- .../Sources/TextFieldComponent.swift | 10 +++++++--- submodules/TelegramUI/Sources/ChatController.swift | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/submodules/TelegramUI/Components/TextFieldComponent/Sources/TextFieldComponent.swift b/submodules/TelegramUI/Components/TextFieldComponent/Sources/TextFieldComponent.swift index ad7753684b..24f6b9349c 100644 --- a/submodules/TelegramUI/Components/TextFieldComponent/Sources/TextFieldComponent.swift +++ b/submodules/TelegramUI/Components/TextFieldComponent/Sources/TextFieldComponent.swift @@ -825,9 +825,13 @@ public final class TextFieldComponent: Component { var rightmostX = lineRect.maxX + padding let rightmostY = lineRect.minY + self.textView.textContainerInset.top - let stringIndex = self.textView.text.index(self.textView.text.startIndex, offsetBy: lineRange.location + lineRange.length - 1) - if self.textView.text[stringIndex] == " " { - rightmostX -= 3.0 + let nsString = (self.textView.text as NSString) + let firstLineEndRange = NSMakeRange(lineRange.location + lineRange.length - 1, 1) + if nsString.length > firstLineEndRange.location + firstLineEndRange.length { + let lastChar = nsString.substring(with: firstLineEndRange) + if lastChar == " " { + rightmostX -= 2.0 + } } return CGPoint(x: rightmostX, y: rightmostY) diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 22b5b41351..8ec6cdceca 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -19381,6 +19381,8 @@ func canAddMessageReactions(message: Message) -> Bool { if story.isMention { return false } + } else if let _ = media as? TelegramMediaExpiredContent { + return false } } return true