Skip to content

Commit

Permalink
Merge branch 'master' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac committed Aug 12, 2024
2 parents 0a31b63 + efb0d78 commit 4ea0a99
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 91 deletions.
88 changes: 10 additions & 78 deletions submodules/BrowserUI/Sources/BrowserDocumentContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
}

Expand All @@ -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 {
Expand All @@ -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() {
Expand All @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ private func requestSendStarsReaction(postbox: Postbox, network: Network, stateM
flags |= 1 << 0
}

let signal: Signal<Never, RequestUpdateMessageReactionError> = network.request(Api.functions.messages.sendPaidReaction(flags: 0, peer: inputPeer, msgId: messageId.id, count: count, randomId: Int64(bitPattern: randomId)))
let signal: Signal<Never, RequestUpdateMessageReactionError> = network.request(Api.functions.messages.sendPaidReaction(flags: flags, peer: inputPeer, msgId: messageId.id, count: count, randomId: Int64(bitPattern: randomId)))
|> mapError { _ -> RequestUpdateMessageReactionError in
return .generic
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1402,6 +1402,9 @@ public class PeerAllowedReactionsScreen: ViewControllerComponentContainer {
case .empty:
isEnabled = false
}
if let starsAllowed = reactionSettings.starsAllowed, starsAllowed {
isEnabled = true
}
}

var missingReactionFiles: [Int64] = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -1104,4 +1106,8 @@ public final class StarsTransactionsScreen: ViewControllerComponentContainer {
deinit {
self.navigateDisposable.dispose()
}

public func update() {
self.subscriptionsContext.loadMore()
}
}

0 comments on commit 4ea0a99

Please sign in to comment.