Skip to content

Commit 1c3b749

Browse files
committed
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
2 parents 48e873c + a39987a commit 1c3b749

File tree

7 files changed

+63
-25
lines changed

7 files changed

+63
-25
lines changed

submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelComponent.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ public final class ChatTextInputPanelComponent: Component {
182182
let insets: UIEdgeInsets
183183
let maxHeight: CGFloat
184184
let maxLength: Int?
185+
let allowConsecutiveNewlines: Bool
185186
let sendAction: (() -> Void)?
186187
let sendContextAction: ((UIView, ContextGesture) -> Void)?
187188

@@ -206,6 +207,7 @@ public final class ChatTextInputPanelComponent: Component {
206207
insets: UIEdgeInsets,
207208
maxHeight: CGFloat,
208209
maxLength: Int?,
210+
allowConsecutiveNewlines: Bool,
209211
sendAction: (() -> Void)?,
210212
sendContextAction: ((UIView, ContextGesture) -> Void)?
211213
) {
@@ -229,6 +231,7 @@ public final class ChatTextInputPanelComponent: Component {
229231
self.insets = insets
230232
self.maxHeight = maxHeight
231233
self.maxLength = maxLength
234+
self.allowConsecutiveNewlines = allowConsecutiveNewlines
232235
self.sendAction = sendAction
233236
self.sendContextAction = sendContextAction
234237
}
@@ -294,6 +297,9 @@ public final class ChatTextInputPanelComponent: Component {
294297
if lhs.maxLength != rhs.maxLength {
295298
return false
296299
}
300+
if lhs.allowConsecutiveNewlines != rhs.allowConsecutiveNewlines {
301+
return false
302+
}
297303
if (lhs.sendAction == nil) != (rhs.sendAction == nil) {
298304
return false
299305
}
@@ -1013,6 +1019,8 @@ public final class ChatTextInputPanelComponent: Component {
10131019
}
10141020
}
10151021

1022+
panelNode.allowConsecutiveNewlines = component.allowConsecutiveNewlines
1023+
10161024
if let resetInputState = component.externalState.resetInputState {
10171025
component.externalState.resetInputState = nil
10181026
let _ = resetInputState

submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg
407407
public var customSendIsDisabled: Bool = false
408408
public var customInputTextMaxLength: Int?
409409
public var customSwitchToKeyboard: (() -> Void)?
410+
public var allowConsecutiveNewlines = true
410411

411412
private var starReactionButton: ComponentView<Empty>?
412413
private var liveMicrophoneButton: ComponentView<Empty>?
@@ -4952,24 +4953,41 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg
49524953
}
49534954
}
49544955
}
4955-
4956+
4957+
let string = NSMutableAttributedString(attributedString: editableTextNode.attributedText ?? NSAttributedString())
4958+
var textColor: UIColor = .black
4959+
var accentTextColor: UIColor = .blue
4960+
var baseFontSize: CGFloat = 17.0
4961+
if let presentationInterfaceState = self.presentationInterfaceState {
4962+
textColor = presentationInterfaceState.theme.chat.inputPanel.inputTextColor
4963+
accentTextColor = presentationInterfaceState.theme.chat.inputPanel.panelControlAccentColor
4964+
baseFontSize = max(minInputFontSize, presentationInterfaceState.fontSize.baseDisplaySize)
4965+
if "".isEmpty {
4966+
baseFontSize = 17.0
4967+
}
4968+
}
4969+
let cleanReplacementString = textAttributedStringForStateText(context: context, stateText: NSAttributedString(string: cleanText), fontSize: baseFontSize, textColor: textColor, accentTextColor: accentTextColor, writingDirection: nil, spoilersRevealed: self.spoilersRevealed, availableEmojis: (self.context?.animatedEmojiStickersValue.keys).flatMap(Set.init) ?? Set(), emojiViewProvider: self.emojiViewProvider, makeCollapsedQuoteAttachment: { text, attributes in
4970+
return ChatInputTextCollapsedQuoteAttachmentImpl(text: text, attributes: attributes)
4971+
})
4972+
string.replaceCharacters(in: range, with: cleanReplacementString)
4973+
4974+
var resetText = false
49564975
if cleanText != text {
4957-
let string = NSMutableAttributedString(attributedString: editableTextNode.attributedText ?? NSAttributedString())
4958-
var textColor: UIColor = .black
4959-
var accentTextColor: UIColor = .blue
4960-
var baseFontSize: CGFloat = 17.0
4961-
if let presentationInterfaceState = self.presentationInterfaceState {
4962-
textColor = presentationInterfaceState.theme.chat.inputPanel.inputTextColor
4963-
accentTextColor = presentationInterfaceState.theme.chat.inputPanel.panelControlAccentColor
4964-
baseFontSize = max(minInputFontSize, presentationInterfaceState.fontSize.baseDisplaySize)
4965-
if "".isEmpty {
4966-
baseFontSize = 17.0
4976+
resetText = true
4977+
}
4978+
4979+
if !self.allowConsecutiveNewlines {
4980+
while string.string.range(of: "\n\n") != nil {
4981+
if let range = string.string.range(of: "\n\n") {
4982+
let rawRange = NSRange(range, in: string.string)
4983+
let firstNewline = string.attributedSubstring(from: NSRange(location: rawRange.location, length: 1))
4984+
string.replaceCharacters(in: rawRange, with: firstNewline)
4985+
resetText = true
49674986
}
49684987
}
4969-
let cleanReplacementString = textAttributedStringForStateText(context: context, stateText: NSAttributedString(string: cleanText), fontSize: baseFontSize, textColor: textColor, accentTextColor: accentTextColor, writingDirection: nil, spoilersRevealed: self.spoilersRevealed, availableEmojis: (self.context?.animatedEmojiStickersValue.keys).flatMap(Set.init) ?? Set(), emojiViewProvider: self.emojiViewProvider, makeCollapsedQuoteAttachment: { text, attributes in
4970-
return ChatInputTextCollapsedQuoteAttachmentImpl(text: text, attributes: attributes)
4971-
})
4972-
string.replaceCharacters(in: range, with: cleanReplacementString)
4988+
}
4989+
4990+
if resetText {
49734991
self.textInputNode?.attributedText = string
49744992
self.textInputNode?.selectedRange = NSMakeRange(range.lowerBound + cleanReplacementString.length, 0)
49754993
self.updateTextNodeText(animated: true)

submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,7 @@ public final class MessageInputPanelComponent: Component {
11251125
insets: UIEdgeInsets(top: 0.0, left: 0.0, bottom: component.bottomInset, right: 0.0),
11261126
maxHeight: availableSize.height,
11271127
maxLength: component.maxLength,
1128+
allowConsecutiveNewlines: false,
11281129
sendAction: { [weak self] in
11291130
guard let self, let component = self.component else {
11301131
return

submodules/TelegramUI/Components/ShareWithPeersScreen/Sources/ShareWithPeersScreen.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,6 @@ final class ShareWithPeersScreenComponent: Component {
18331833
sectionOffset += footerSize.height
18341834
} else if section.id == 4 && section.itemCount > 0 {
18351835
var sectionItemOffset: CGFloat = 0.0
1836-
//TODO:release
18371836
if self.selectedOptions.contains(.pin) && !"".isEmpty {
18381837
let itemFrame = CGRect(origin: CGPoint(x: itemLayout.sideInset, y: sectionOffset + section.insets.top + sectionItemOffset), size: CGSize(width: itemLayout.containerSize.width, height: section.itemHeight))
18391838
if !visibleBounds.intersects(itemFrame) {
@@ -2732,10 +2731,6 @@ final class ShareWithPeersScreenComponent: Component {
27322731
if hasCover {
27332732
itemCount += 1
27342733
}
2735-
//TODO:release
2736-
/*if self.selectedOptions.contains(.pin) {
2737-
itemCount += 1
2738-
}*/
27392734
if itemCount != 0 {
27402735
sections.append(ItemLayout.Section(
27412736
id: 4,

submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -952,9 +952,15 @@ private final class StoryContainerScreenComponent: Component {
952952
} else {
953953
let itemViewFrame = currentItemView.convert(currentItemView.bounds, to: self)
954954
if location.x < itemViewFrame.minX {
955-
self.navigate(direction: .previous)
955+
if slice.previousItemId == nil && currentItemView.preventTapNavigation() {
956+
} else {
957+
self.navigate(direction: .previous)
958+
}
956959
} else if location.x > itemViewFrame.maxX {
957-
self.navigate(direction: .next)
960+
if slice.nextItemId == nil && currentItemView.preventTapNavigation() {
961+
} else {
962+
self.navigate(direction: .next)
963+
}
958964
}
959965
}
960966
}

submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,16 @@ public final class StoryItemSetContainerComponent: Component {
945945
return false
946946
}
947947

948+
func preventTapNavigation() -> Bool {
949+
guard let component = self.component else {
950+
return false
951+
}
952+
if case .liveStream = component.slice.item.storyItem.media {
953+
return true
954+
}
955+
return false
956+
}
957+
948958
func deactivateInput() {
949959
if let view = self.inputPanel.view as? MessageInputPanelComponent.View, view.canDeactivateInput() {
950960
self.sendMessageContext.currentInputMode = .text
@@ -3234,7 +3244,7 @@ public final class StoryItemSetContainerComponent: Component {
32343244
}
32353245
self.sendMessageContext.performShareAction(view: self)
32363246
} : nil,
3237-
paidMessageAction: isLiveStream && !component.isEmbeddedInCamera ? { [weak self] in
3247+
paidMessageAction: isLiveStream && component.slice.item.peerId != component.context.account.peerId && !component.isEmbeddedInCamera ? { [weak self] in
32383248
guard let self else {
32393249
return
32403250
}
@@ -4269,7 +4279,7 @@ public final class StoryItemSetContainerComponent: Component {
42694279
closeFriendIcon.view?.removeFromSuperview()
42704280
}
42714281

4272-
if case .liveStream = component.slice.item.storyItem.media {
4282+
if case .liveStream = component.slice.item.storyItem.media, !component.isEmbeddedInCamera {
42734283
let pictureInPictureIcon: ComponentView<Empty>
42744284
var pictureInPictureIconTransition: ComponentTransition = itemChanged ? .immediate : .easeInOut(duration: 0.2)
42754285
if let current = self.pictureInPictureIcon {

versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"app": "12.2.1",
2+
"app": "12.2",
33
"xcode": "26.0",
44
"bazel": "8.3.1:0cac3a67dc5429c68272dc6944104952e9e4cf84b29d126a5ff3fbaa59045217",
55
"macos": "26"

0 commit comments

Comments
 (0)