From 42de4756aafdb38ce720af8fb691d9a553d5921c Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 13 Aug 2024 01:19:23 +0200 Subject: [PATCH] Various fixes --- .../Sources/BrowserDocumentContent.swift | 33 +------------------ .../TelegramEngine/Payments/Stars.swift | 3 -- .../Sources/StarsTransactionScreen.swift | 20 +++++++++-- .../Sources/StarsTransactionsScreen.swift | 14 +++++--- 4 files changed, 28 insertions(+), 42 deletions(-) diff --git a/submodules/BrowserUI/Sources/BrowserDocumentContent.swift b/submodules/BrowserUI/Sources/BrowserDocumentContent.swift index bb3774ba879..c17a2911ed8 100644 --- a/submodules/BrowserUI/Sources/BrowserDocumentContent.swift +++ b/submodules/BrowserUI/Sources/BrowserDocumentContent.swift @@ -346,7 +346,7 @@ final class BrowserDocumentContent: UIView, BrowserContent, WKNavigationDelegate self.updateScrollingOffset(isReset: true, transition: .spring(duration: 0.4)) } - func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) + func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) { self.updateFontState(self.currentFontState, force: true) } @@ -376,37 +376,6 @@ final class BrowserDocumentContent: UIView, BrowserContent, WKNavigationDelegate decisionHandler(.prompt) } - -// @available(iOS 13.0, *) -// func webView(_ webView: WKWebView, contextMenuConfigurationForElement elementInfo: WKContextMenuElementInfo, completionHandler: @escaping (UIContextMenuConfiguration?) -> Void) { -// guard let url = elementInfo.linkURL else { -// completionHandler(nil) -// return -// } -// let presentationData = self.context.sharedContext.currentPresentationData.with { $0 } -// let configuration = UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { [weak self] _ in -// return UIMenu(title: "", children: [ -// UIAction(title: presentationData.strings.Browser_ContextMenu_Open, image: generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Browser"), color: presentationData.theme.contextMenu.primaryColor), handler: { [weak self] _ in -// self?.open(url: url.absoluteString, new: false) -// }), -// UIAction(title: presentationData.strings.Browser_ContextMenu_OpenInNewTab, image: generateTintedImage(image: UIImage(bundleImageName: "Instant View/NewTab"), color: presentationData.theme.contextMenu.primaryColor), handler: { [weak self] _ in -// self?.open(url: url.absoluteString, new: true) -// }), -// UIAction(title: presentationData.strings.Browser_ContextMenu_AddToReadingList, image: generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/ReadingList"), color: presentationData.theme.contextMenu.primaryColor), handler: { _ in -// let _ = try? SSReadingList.default()?.addItem(with: url, title: nil, previewText: nil) -// }), -// UIAction(title: presentationData.strings.Browser_ContextMenu_CopyLink, image: generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Copy"), color: presentationData.theme.contextMenu.primaryColor), handler: { [weak self] _ in -// UIPasteboard.general.string = url.absoluteString -// self?.present(UndoOverlayController(presentationData: presentationData, content: .linkCopied(text: presentationData.strings.Conversation_LinkCopied), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), nil) -// }), -// UIAction(title: presentationData.strings.Browser_ContextMenu_Share, image: generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Forward"), color: presentationData.theme.contextMenu.primaryColor), handler: { [weak self] _ in -// self?.share(url: url.absoluteString) -// }) -// ]) -// } -// completionHandler(configuration) -// } - private func open(url: String, new: Bool) { let subject: BrowserScreen.Subject = .webPage(url: url) if new, let navigationController = self.getNavigationController() { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Payments/Stars.swift b/submodules/TelegramCore/Sources/TelegramEngine/Payments/Stars.swift index 3a8fabd8e28..f93551a46ec 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Payments/Stars.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Payments/Stars.swift @@ -1093,9 +1093,6 @@ func _internal_sendStarsPaymentForm(account: Account, formId: Int64, source: Bot return account.network.request(Api.functions.payments.sendStarsForm(flags: flags, formId: formId, invoice: invoice)) |> map { result -> SendBotPaymentResult in - - - switch result { case let .paymentResult(updates): account.stateManager.addUpdates(updates) diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionScreen/Sources/StarsTransactionScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionScreen/Sources/StarsTransactionScreen.swift index a03c0ee0d2b..899149a3619 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionScreen/Sources/StarsTransactionScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionScreen/Sources/StarsTransactionScreen.swift @@ -277,9 +277,23 @@ private final class StarsTransactionSheetContent: CombinedComponent { } isCancelled = true } else { - statusText = strings.Stars_Transaction_Subscription_Active(stringForMediumDate(timestamp: subscription.untilDate, strings: strings, dateTimeFormat: dateTimeFormat, withTime: false)).string - buttonText = strings.Stars_Transaction_Subscription_Cancel - buttonIsDestructive = true + if subscription.flags.contains(.isCancelled) { + statusText = strings.Stars_Transaction_Subscription_Cancelled + statusIsDestructive = true + if date > Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970) { + buttonText = strings.Stars_Transaction_Subscription_Renew + } else { + if let _ = subscription.inviteHash, !isKicked { + buttonText = strings.Stars_Transaction_Subscription_JoinAgainChannel + } else { + buttonText = strings.Common_OK + } + } + } else { + statusText = strings.Stars_Transaction_Subscription_Active(stringForMediumDate(timestamp: subscription.untilDate, strings: strings, dateTimeFormat: dateTimeFormat, withTime: false)).string + buttonText = strings.Stars_Transaction_Subscription_Cancel + buttonIsDestructive = true + } } case let .transaction(transaction, parentPeer): if let _ = transaction.subscriptionPeriod { diff --git a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift index d85c0e58e39..0b1390aebb8 100644 --- a/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift +++ b/submodules/TelegramUI/Components/Stars/StarsTransactionsScreen/Sources/StarsTransactionsScreen.swift @@ -969,13 +969,15 @@ public final class StarsTransactionsScreen: ViewControllerComponentContainer { return } if subscription.untilDate > Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970) { - if let channel = subscription.peer._asPeer() as? TelegramChannel, channel.participationStatus == .left { + var updated = false + if let channel = subscription.peer._asPeer() as? TelegramChannel, channel.participationStatus == .left && !subscription.flags.contains(.isCancelled) { let _ = self.context.engine.payments.fulfillStarsSubscription(peerId: context.account.peerId, subscriptionId: subscription.id).startStandalone() + updated = true + } + if !updated { if subscription.flags.contains(.isCancelled) { self.subscriptionsContext.updateSubscription(id: subscription.id, cancel: false) - } - } else { - if !subscription.flags.contains(.isCancelled) { + } else { self.subscriptionsContext.updateSubscription(id: subscription.id, cancel: true) } } @@ -1104,4 +1106,8 @@ public final class StarsTransactionsScreen: ViewControllerComponentContainer { deinit { self.navigateDisposable.dispose() } + + public func update() { + self.subscriptionsContext.loadMore() + } }