Various fixes

This commit is contained in:
Ilya Laktyushin 2024-08-13 01:19:23 +02:00
parent 09da967592
commit 42de4756aa
4 changed files with 28 additions and 42 deletions

View File

@ -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() {

View File

@ -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)

View File

@ -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 {

View File

@ -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()
}
}