diff --git a/submodules/BrowserUI/Sources/BrowserDocumentContent.swift b/submodules/BrowserUI/Sources/BrowserDocumentContent.swift index 065eb5180d9..c17a2911ed8 100644 --- a/submodules/BrowserUI/Sources/BrowserDocumentContent.swift +++ b/submodules/BrowserUI/Sources/BrowserDocumentContent.swift @@ -262,28 +262,6 @@ final class BrowserDocumentContent: UIView, BrowserContent, WKNavigationDelegate self.webView.scrollView.scrollIndicatorInsets = UIEdgeInsets(top: 0.0, left: -insets.left, bottom: 0.0, right: -insets.right) self.webView.scrollView.horizontalScrollIndicatorInsets = UIEdgeInsets(top: 0.0, left: -insets.left, bottom: 0.0, right: -insets.right) - -// if let error = self.currentError { -// let errorSize = self.errorView.update( -// transition: .immediate, -// component: AnyComponent( -// ErrorComponent( -// theme: self.presentationData.theme, -// title: self.presentationData.strings.Browser_ErrorTitle, -// text: error.localizedDescription -// ) -// ), -// environment: {}, -// containerSize: CGSize(width: size.width - insets.left - insets.right - 72.0, height: size.height) -// ) -// if self.errorView.superview == nil { -// self.addSubview(self.errorView) -// self.errorView.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.25) -// } -// self.errorView.frame = CGRect(origin: CGPoint(x: floorToScreenPixels((size.width - errorSize.width) / 2.0), y: insets.top + floorToScreenPixels((size.height - insets.top - insets.bottom - errorSize.height) / 2.0)), size: errorSize) -// } else if self.errorView.superview != nil { -// self.errorView.removeFromSuperview() -// } } private func updateState(_ f: (BrowserContentState) -> BrowserContentState) { @@ -369,7 +347,6 @@ final class BrowserDocumentContent: UIView, BrowserContent, WKNavigationDelegate } func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) { -// self.currentError = nil self.updateFontState(self.currentFontState, force: true) } @@ -380,29 +357,7 @@ final class BrowserDocumentContent: UIView, BrowserContent, WKNavigationDelegate .withUpdatedForwardList(webView.backForwardList.forwardList.map { BrowserContentState.HistoryItem(webItem: $0) }) } } - -// func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) { -// if (error as NSError).code != -999 { -// self.currentError = error -// } else { -// self.currentError = nil -// } -// if let (size, insets) = self.validLayout { -// self.updateLayout(size: size, insets: insets, transition: .immediate) -// } -// } -// -// func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) { -// if (error as NSError).code != -999 { -// self.currentError = error -// } else { -// self.currentError = nil -// } -// if let (size, insets) = self.validLayout { -// self.updateLayout(size: size, insets: insets, transition: .immediate) -// } -// } - + func webView(_ webView: WKWebView, createWebViewWith configuration: WKWebViewConfiguration, for navigationAction: WKNavigationAction, windowFeatures: WKWindowFeatures) -> WKWebView? { if navigationAction.targetFrame == nil { if let url = navigationAction.request.url?.absoluteString { @@ -421,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() { @@ -478,6 +402,14 @@ final class BrowserDocumentContent: UIView, BrowserContent, WKNavigationDelegate } func makeContentSnapshotView() -> UIView? { - return nil + let configuration = WKSnapshotConfiguration() + configuration.rect = CGRect(origin: .zero, size: self.webView.frame.size) + + let imageView = UIImageView() + imageView.frame = CGRect(origin: .zero, size: self.webView.frame.size) + self.webView.takeSnapshot(with: configuration, completionHandler: { image, _ in + imageView.image = image + }) + return imageView } } diff --git a/submodules/TelegramCore/Sources/State/MessageReactions.swift b/submodules/TelegramCore/Sources/State/MessageReactions.swift index 9aa3c8f31a4..55b47ce2120 100644 --- a/submodules/TelegramCore/Sources/State/MessageReactions.swift +++ b/submodules/TelegramCore/Sources/State/MessageReactions.swift @@ -389,7 +389,7 @@ private func requestSendStarsReaction(postbox: Postbox, network: Network, stateM flags |= 1 << 0 } - let signal: Signal = network.request(Api.functions.messages.sendPaidReaction(flags: 0, peer: inputPeer, msgId: messageId.id, count: count, randomId: Int64(bitPattern: randomId))) + let signal: Signal = network.request(Api.functions.messages.sendPaidReaction(flags: flags, peer: inputPeer, msgId: messageId.id, count: count, randomId: Int64(bitPattern: randomId))) |> mapError { _ -> RequestUpdateMessageReactionError in return .generic } 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/PeerAllowedReactionsScreen/Sources/PeerAllowedReactionsScreen.swift b/submodules/TelegramUI/Components/PeerAllowedReactionsScreen/Sources/PeerAllowedReactionsScreen.swift index a8bbe1b0166..b347a46bfda 100644 --- a/submodules/TelegramUI/Components/PeerAllowedReactionsScreen/Sources/PeerAllowedReactionsScreen.swift +++ b/submodules/TelegramUI/Components/PeerAllowedReactionsScreen/Sources/PeerAllowedReactionsScreen.swift @@ -1402,6 +1402,9 @@ public class PeerAllowedReactionsScreen: ViewControllerComponentContainer { case .empty: isEnabled = false } + if let starsAllowed = reactionSettings.starsAllowed, starsAllowed { + isEnabled = true + } } var missingReactionFiles: [Int64] = [] diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift index 246826732e0..41a613f8f56 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoScreen.swift @@ -1993,9 +1993,17 @@ private func editingItems(data: PeerInfoScreenData?, state: PeerInfoState, chatL case .all: label = presentationData.strings.PeerInfo_LabelAllReactions case .empty: - label = presentationData.strings.PeerInfo_ReactionsDisabled + if let starsAllowed = reactionSettings.starsAllowed, starsAllowed { + label = "1" + } else { + label = presentationData.strings.PeerInfo_ReactionsDisabled + } case let .limited(reactions): - label = "\(reactions.count)" + var countValue = reactions.count + if let starsAllowed = reactionSettings.starsAllowed, starsAllowed { + countValue += 1 + } + label = "\(countValue)" } } else { label = "" 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() + } }