From de6f737bc106c29f9c0478d9456dd0d0bcee2d33 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Fri, 29 Nov 2024 03:26:24 +0400 Subject: [PATCH] Various fixes --- .../LegacyComponents/TGPhotoCaptionInputMixin.h | 3 +++ .../Sources/TGMediaPickerGalleryInterfaceView.m | 10 +++++++++- .../Sources/TGPhotoCaptionInputMixin.m | 14 +++++++++----- .../Sources/LegacyAttachmentMenu.swift | 5 +++-- .../PeerInfoScreen/Sources/PeerInfoScreen.swift | 2 +- submodules/TelegramUI/Sources/ChatController.swift | 10 +++++++--- versions.json | 2 +- 7 files changed, 33 insertions(+), 13 deletions(-) diff --git a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoCaptionInputMixin.h b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoCaptionInputMixin.h index 605607abaa..bd3436c766 100644 --- a/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoCaptionInputMixin.h +++ b/submodules/LegacyComponents/PublicHeaders/LegacyComponents/TGPhotoCaptionInputMixin.h @@ -26,8 +26,11 @@ @property (nonatomic, copy) void (^timerUpdated)(NSNumber *timeout); @property (nonatomic, copy) void (^captionIsAboveUpdated)(bool captionIsAbove); +@property (nonatomic, readonly) bool editing; + - (void)createInputPanelIfNeeded; - (void)beginEditing; +- (void)finishEditing; - (void)enableDismissal; - (void)onAnimateOut; diff --git a/submodules/LegacyComponents/Sources/TGMediaPickerGalleryInterfaceView.m b/submodules/LegacyComponents/Sources/TGMediaPickerGalleryInterfaceView.m index e0aafc3c4d..d4d0322e66 100644 --- a/submodules/LegacyComponents/Sources/TGMediaPickerGalleryInterfaceView.m +++ b/submodules/LegacyComponents/Sources/TGMediaPickerGalleryInterfaceView.m @@ -175,7 +175,15 @@ [strongSelf.window endEditing:true]; strongSelf->_portraitToolbarView.doneButton.userInteractionEnabled = false; strongSelf->_landscapeToolbarView.doneButton.userInteractionEnabled = false; - strongSelf->_donePressed(strongSelf->_currentItem); + + if (strongSelf->_captionMixin.editing) { + [strongSelf->_captionMixin finishEditing]; + TGDispatchAfter(0.1, dispatch_get_main_queue(), ^{ + strongSelf->_donePressed(strongSelf->_currentItem); + }); + } else { + strongSelf->_donePressed(strongSelf->_currentItem); + } [strongSelf->_captionMixin onAnimateOut]; }; diff --git a/submodules/LegacyComponents/Sources/TGPhotoCaptionInputMixin.m b/submodules/LegacyComponents/Sources/TGPhotoCaptionInputMixin.m index b069cf2410..dbd7816265 100644 --- a/submodules/LegacyComponents/Sources/TGPhotoCaptionInputMixin.m +++ b/submodules/LegacyComponents/Sources/TGPhotoCaptionInputMixin.m @@ -181,11 +181,7 @@ #pragma mark - -- (void)handleDismissTap:(UITapGestureRecognizer *)gestureRecognizer -{ - if (gestureRecognizer.state != UIGestureRecognizerStateRecognized) - return; - +- (void)finishEditing { if ([self.inputPanel dismissInput]) { _editing = false; @@ -194,6 +190,14 @@ } } +- (void)handleDismissTap:(UITapGestureRecognizer *)gestureRecognizer +{ + if (gestureRecognizer.state != UIGestureRecognizerStateRecognized) + return; + + [self finishEditing]; +} + #pragma mark - Input Panel Delegate - (void)setContentAreaHeight:(CGFloat)contentAreaHeight diff --git a/submodules/LegacyMediaPickerUI/Sources/LegacyAttachmentMenu.swift b/submodules/LegacyMediaPickerUI/Sources/LegacyAttachmentMenu.swift index ea428cb7bb..2e2d07625f 100644 --- a/submodules/LegacyMediaPickerUI/Sources/LegacyAttachmentMenu.swift +++ b/submodules/LegacyMediaPickerUI/Sources/LegacyAttachmentMenu.swift @@ -155,7 +155,7 @@ public func legacyStoryMediaEditor(context: AccountContext, item: TGMediaEditabl }) } -public func legacyMediaEditor(context: AccountContext, peer: Peer, threadTitle: String?, media: AnyMediaReference, mode: LegacyMediaEditorMode, initialCaption: NSAttributedString, snapshots: [UIView], transitionCompletion: (() -> Void)?, getCaptionPanelView: @escaping () -> TGCaptionPanelView?, sendMessagesWithSignals: @escaping ([Any]?, Bool, Int32) -> Void, present: @escaping (ViewController, Any?) -> Void) { +public func legacyMediaEditor(context: AccountContext, peer: Peer, threadTitle: String?, media: AnyMediaReference, mode: LegacyMediaEditorMode, initialCaption: NSAttributedString, snapshots: [UIView], transitionCompletion: (() -> Void)?, getCaptionPanelView: @escaping () -> TGCaptionPanelView?, sendMessagesWithSignals: @escaping ([Any]?, Bool, Int32, Bool) -> Void, present: @escaping (ViewController, Any?) -> Void) { let _ = (fetchMediaData(context: context, postbox: context.account.postbox, userLocation: .other, mediaReference: media) |> deliverOnMainQueue).start(next: { (value, isImage) in guard case let .data(data) = value, data.complete else { @@ -215,7 +215,8 @@ public func legacyMediaEditor(context: AccountContext, peer: Peer, threadTitle: let signals = TGCameraController.resultSignals(for: nil, editingContext: editingContext, currentItem: selectableResult, storeAssets: false, saveEditedPhotos: false, descriptionGenerator: { _1, _2, _3 in nativeGenerator(_1, _2, _3, nil) }) - sendMessagesWithSignals(signals, false, 0) + let isCaptionAbove = editingContext?.isCaptionAbove() ?? false + sendMessagesWithSignals(signals, false, 0, isCaptionAbove) }, dismissed: { [weak legacyController] in legacyController?.dismiss() }) diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift index 27d8d36560..9196b3df55 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift @@ -5276,7 +5276,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro transitionCompletion() }, getCaptionPanelView: { return nil - }, sendMessagesWithSignals: { [weak self] signals, _, _ in + }, sendMessagesWithSignals: { [weak self] signals, _, _, _ in if let strongSelf = self { strongSelf.enqueueMediaMessageDisposable.set((legacyAssetPickerEnqueueMessages(context: strongSelf.context, account: strongSelf.context.account, signals: signals!) |> deliverOnMainQueue).startStrict(next: { [weak self] messages in diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 12d38e146d..83ff745532 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -1462,9 +1462,13 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G transitionCompletion() }, getCaptionPanelView: { [weak self] in return self?.getCaptionPanelView(isFile: false) - }, sendMessagesWithSignals: { [weak self] signals, _, _ in + }, sendMessagesWithSignals: { [weak self] signals, _, _, isCaptionAbove in if let strongSelf = self { - strongSelf.enqueueMediaMessages(signals: signals, silentPosting: false) + var parameters: ChatSendMessageActionSheetController.SendParameters? + if isCaptionAbove { + parameters = ChatSendMessageActionSheetController.SendParameters(effect: nil, textIsAboveMedia: true) + } + strongSelf.enqueueMediaMessages(signals: signals, silentPosting: false, parameters: parameters) } }, present: { [weak self] c, a in self?.present(c, in: .window(.root), with: a) @@ -3801,7 +3805,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G let inputText = strongSelf.presentationInterfaceState.interfaceState.effectiveInputState.inputText legacyMediaEditor(context: strongSelf.context, peer: peer, threadTitle: strongSelf.threadInfo?.title, media: mediaReference, mode: .draw, initialCaption: inputText, snapshots: [], transitionCompletion: nil, getCaptionPanelView: { [weak self] in return self?.getCaptionPanelView(isFile: true) - }, sendMessagesWithSignals: { [weak self] signals, _, _ in + }, sendMessagesWithSignals: { [weak self] signals, _, _, _ in if let strongSelf = self { strongSelf.interfaceInteraction?.setupEditMessage(messageId, { _ in }) strongSelf.editMessageMediaWithLegacySignals(signals!) diff --git a/versions.json b/versions.json index dc9b8e2579..20138efedd 100644 --- a/versions.json +++ b/versions.json @@ -1,5 +1,5 @@ { - "app": "11.4", + "app": "11.5", "xcode": "16.0", "bazel": "7.3.1:981f82a470bad1349322b6f51c9c6ffa0aa291dab1014fac411543c12e661dff", "macos": "15.0"