From fba37dcf6318d81009afa8e62ba1658bab41023d Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Thu, 7 Mar 2024 19:19:54 +0400 Subject: [PATCH] Cherry-pick fixes --- .../Sources/TGMediaPickerGalleryPhotoItemView.m | 10 +++++----- .../Sources/PeerNameColorItem.swift | 17 ++++++++++++++++- .../TelegramUI/Sources/ChatController.swift | 13 +------------ .../Sources/NavigateToChatController.swift | 4 +--- .../TelegramUI/Sources/OpenResolvedUrl.swift | 13 +++++++++++-- submodules/WebPBinding/Sources/UIImage+WebP.m | 1 + versions.json | 2 +- 7 files changed, 36 insertions(+), 24 deletions(-) diff --git a/submodules/LegacyComponents/Sources/TGMediaPickerGalleryPhotoItemView.m b/submodules/LegacyComponents/Sources/TGMediaPickerGalleryPhotoItemView.m index 1cc45395ca6..7b6117cf929 100644 --- a/submodules/LegacyComponents/Sources/TGMediaPickerGalleryPhotoItemView.m +++ b/submodules/LegacyComponents/Sources/TGMediaPickerGalleryPhotoItemView.m @@ -248,11 +248,11 @@ - (void)setItem:(TGMediaPickerGalleryPhotoItem *)item synchronously:(bool)synchr }]]; - if (!item.asFile) { - [_facesDisposable setDisposable:[[TGPaintFaceDetector detectFacesInItem:item.editableMediaItem editingContext:item.editingContext] startStrictWithNext:nil file:__FILE_NAME__ line:__LINE__]]; - - return; - } +// if (!item.asFile) { +// [_facesDisposable setDisposable:[[TGPaintFaceDetector detectFacesInItem:item.editableMediaItem editingContext:item.editingContext] startStrictWithNext:nil file:__FILE_NAME__ line:__LINE__]]; +// +// return; +// } _fileInfoLabel.text = nil; diff --git a/submodules/TelegramUI/Components/Settings/PeerNameColorItem/Sources/PeerNameColorItem.swift b/submodules/TelegramUI/Components/Settings/PeerNameColorItem/Sources/PeerNameColorItem.swift index 95cfb9911da..1ee373526bc 100644 --- a/submodules/TelegramUI/Components/Settings/PeerNameColorItem/Sources/PeerNameColorItem.swift +++ b/submodules/TelegramUI/Components/Settings/PeerNameColorItem/Sources/PeerNameColorItem.swift @@ -407,7 +407,7 @@ public final class PeerNameColorItemNode: ListViewItemNode, ItemListItemNode { let rowsCount = ceil(CGFloat(numItems) / CGFloat(itemsPerRow)) - contentSize = CGSize(width: params.width, height: 48.0 * rowsCount) + contentSize = CGSize(width: params.width, height: 10.0 + 42.0 * rowsCount) insets = itemListNeighborsGroupedInsets(neighbors, params) let layout = ListViewItemNodeLayout(contentSize: contentSize, insets: insets) @@ -518,6 +518,7 @@ public final class PeerNameColorItemNode: ListViewItemNode, ItemListItemNode { var origin = CGPoint(x: sideInset, y: 10.0) i = 0 + var validIds = Set() for item in items { let iconItemNode: PeerNameColorIconItemNode let indexKey: Int32 @@ -545,6 +546,20 @@ public final class PeerNameColorItemNode: ListViewItemNode, ItemListItemNode { origin.x = sideInset origin.y += iconSize.height + 10.0 } + + validIds.insert(indexKey) + } + + var removeKeys: [Int32] = [] + for (id, _) in strongSelf.itemNodes { + if !validIds.contains(id) { + removeKeys.append(id) + } + } + for id in removeKeys { + if let itemNode = strongSelf.itemNodes.removeValue(forKey: id) { + itemNode.removeFromSupernode() + } } } }) diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index c0160b6d7cc..2b478c99e69 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -714,11 +714,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if strongSelf.presentVoiceMessageDiscardAlert(action: action, performAction: false) { return false } - - if strongSelf.presentRecordedVoiceMessageDiscardAlert(action: action, performAction: false) { - return false - } - + if case let .customChatContents(customChatContents) = strongSelf.presentationInterfaceState.subject { switch customChatContents.kind { case let .quickReplyMessageInput(_, shortcutType): @@ -14471,13 +14467,6 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G frames: data.frames, framesUpdateTimestamp: data.framesUpdateTimestamp, trimRange: data.trimRange -// control: ChatRecordedMediaPreview.Video.Control( -// updateTrimRange: { [weak self] start, end, updatedEnd, apply in -// if let self, let videoRecorderValue = self.videoRecorderValue { -// videoRecorderValue.updateTrimRange(start: start, end: end, updatedEnd: updatedEnd, apply: apply) -// } -// } -// ) ) )) }.updatedInputTextPanelState { panelState in diff --git a/submodules/TelegramUI/Sources/NavigateToChatController.swift b/submodules/TelegramUI/Sources/NavigateToChatController.swift index 9dc0e6f4c25..c6fc5392293 100644 --- a/submodules/TelegramUI/Sources/NavigateToChatController.swift +++ b/submodules/TelegramUI/Sources/NavigateToChatController.swift @@ -159,9 +159,7 @@ public func navigateToChatControllerImpl(_ params: NavigateToChatControllerParam controller.presentThemeSelection() } if let botStart = params.botStart { - controller.updateChatPresentationInterfaceState(interactive: false, { state -> ChatPresentationInterfaceState in - return state.updatedBotStartPayload(botStart.payload) - }) + controller.startBot(botStart.payload) } if let attachBotStart = params.attachBotStart { controller.presentAttachmentBot(botId: attachBotStart.botId, payload: attachBotStart.payload, justInstalled: attachBotStart.justInstalled) diff --git a/submodules/TelegramUI/Sources/OpenResolvedUrl.swift b/submodules/TelegramUI/Sources/OpenResolvedUrl.swift index c820caf77ab..15720f5ebc1 100644 --- a/submodules/TelegramUI/Sources/OpenResolvedUrl.swift +++ b/submodules/TelegramUI/Sources/OpenResolvedUrl.swift @@ -32,6 +32,7 @@ import AuthorizationUI import ChatFolderLinkPreviewScreen import StoryContainerScreen import WallpaperGalleryScreen +import TelegramStringFormatting private func defaultNavigationForPeerId(_ peerId: PeerId?, navigation: ChatControllerInteractionNavigateToPeer) -> ChatControllerInteractionNavigateToPeer { if case .default = navigation { @@ -986,7 +987,15 @@ func openResolvedUrlImpl( forceDark: forceDark, action: { [weak navigationController] in let _ = (context.engine.payments.applyPremiumGiftCode(slug: slug) - |> deliverOnMainQueue).startStandalone(completed: { + |> deliverOnMainQueue).startStandalone(error: { error in + dismissImpl?() + + if case let .waitForExpiration(date) = error { + let presentationData = context.sharedContext.currentPresentationData.with { $0 } + let dateText = stringForMediumDate(timestamp: date, strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat) + (navigationController?.topViewController as? ViewController)?.present(UndoOverlayController(presentationData: presentationData, content: .info(title: presentationData.strings.Premium_Gift_ApplyLink_AlreadyHasPremium_Title, text: presentationData.strings.Premium_Gift_ApplyLink_AlreadyHasPremium_Text(dateText).string, timeout: nil, customUndoText: nil), elevatedLayout: true, position: .bottom, action: { _ in return true }), in: .window(.root)) + } + }, completed: { dismissImpl?() let controller = PremiumIntroScreen(context: context, source: .settings, forceDark: forceDark, forceHasPremium: true) @@ -1030,7 +1039,7 @@ func openResolvedUrlImpl( (navigationController?.topViewController as? ViewController)?.present(UndoOverlayController(presentationData: presentationData, content: .forward(savedMessages: true, text: peer.id == context.account.peerId ? presentationData.strings.GiftLink_LinkSharedToSavedMessages : presentationData.strings.GiftLink_LinkSharedToChat(peer.compactDisplayTitle).string), elevatedLayout: false, animateInAsReplacement: true, action: { _ in return false }), in: .window(.root)) let _ = (enqueueMessages(account: context.account, peerId: peer.id, messages: messages) - |> deliverOnMainQueue).startStandalone() + |> deliverOnMainQueue).startStandalone() if let peerSelectionController = peerSelectionController { peerSelectionController.dismiss() } diff --git a/submodules/WebPBinding/Sources/UIImage+WebP.m b/submodules/WebPBinding/Sources/UIImage+WebP.m index c4a07eed728..c6a1d9d3711 100644 --- a/submodules/WebPBinding/Sources/UIImage+WebP.m +++ b/submodules/WebPBinding/Sources/UIImage+WebP.m @@ -87,6 +87,7 @@ + (NSData * _Nullable)convertToWebP:(UIImage * _Nonnull)image quality:(CGFloat)q CGContextRef context = CGBitmapContextCreate(rawData, width, height, bitsPerComponent, bytesPerRow, colorSpace, kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big); CGColorSpaceRelease(colorSpace); + CGContextClearRect(context, CGRectMake(0, 0, width, height)); CGContextDrawImage(context, CGRectMake(0, 0, width, height), imageRef); CGContextRelease(context); diff --git a/versions.json b/versions.json index fbfb35aba9b..82129a23516 100644 --- a/versions.json +++ b/versions.json @@ -1,5 +1,5 @@ { - "app": "10.9.1", + "app": "10.9.2", "bazel": "7.0.2", "xcode": "15.2", "macos": "13.0"