Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios

This commit is contained in:
Mikhail Filimonov
2024-04-04 16:36:24 +04:00
162 changed files with 1856 additions and 1046 deletions
@@ -11884,3 +11884,11 @@ Sorry for the inconvenience.";
"BusinessLink.ErrorExpired" = "Link Expired";
"WebApp.AlertBiometryAccessText" = "Do you want to allow %@ to use Face ID?";
"StoryList.SubtitleArchived_1" = "1 archived post";
"StoryList.SubtitleArchived_any" = "%d archived posts";
"Business.AdsTitle" = "ADS IN CHANNELS";
"Business.DontHideAds" = "Do Not Hide Ads";
"Business.AdsInfo" = "As a Premium subscriber, you don't see any ads on Telegram, but you can turn them on, for example, to view your own ads that you launched on the [Telegram Ad Platform >]()";
"Business.AdsInfo_URL" = "https://promote.telegram.org";
@@ -995,4 +995,71 @@ typedef NS_ENUM(NSInteger, ASLayoutEngineType) {
@property (nullable, weak) ASDisplayNode *asyncdisplaykit_node;
@end
@protocol ASGestureRecognizerDelegate <NSObject>
@optional
// called when a gesture recognizer attempts to transition out of UIGestureRecognizerStatePossible. returning NO causes it to transition to UIGestureRecognizerStateFailed
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer;
// called when the recognition of one of gestureRecognizer or otherGestureRecognizer would be blocked by the other
// return YES to allow both to recognize simultaneously. the default implementation returns NO (by default no two gestures can be recognized simultaneously)
//
// note: returning YES is guaranteed to allow simultaneous recognition. returning NO is not guaranteed to prevent simultaneous recognition, as the other gesture's delegate may return YES
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer;
// called once per attempt to recognize, so failure requirements can be determined lazily and may be set up between recognizers across view hierarchies
// return YES to set up a dynamic failure requirement between gestureRecognizer and otherGestureRecognizer
//
// note: returning YES is guaranteed to set up the failure requirement. returning NO does not guarantee that there will not be a failure requirement as the other gesture's counterpart delegate or subclass methods may return YES
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRequireFailureOfGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer API_AVAILABLE(ios(7.0));
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldBeRequiredToFailByGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer API_AVAILABLE(ios(7.0));
// called before touchesBegan:withEvent: is called on the gesture recognizer for a new touch. return NO to prevent the gesture recognizer from seeing this touch
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch;
// called before pressesBegan:withEvent: is called on the gesture recognizer for a new press. return NO to prevent the gesture recognizer from seeing this press
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceivePress:(UIPress *)press;
// called once before either -gestureRecognizer:shouldReceiveTouch: or -gestureRecognizer:shouldReceivePress:
// return NO to prevent the gesture recognizer from seeing this event
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveEvent:(UIEvent *)event API_AVAILABLE(ios(13.4), tvos(13.4)) API_UNAVAILABLE(watchos);
@end
@protocol ASScrollViewDelegate <NSObject>
@optional
- (void)scrollViewDidScroll:(UIScrollView *)scrollView; // any offset changes
- (void)scrollViewDidZoom:(UIScrollView *)scrollView API_AVAILABLE(ios(3.2)); // any zoom scale changes
// called on start of dragging (may require some time and or distance to move)
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;
// called on finger up if the user dragged. velocity is in points/millisecond. targetContentOffset may be changed to adjust where the scroll view comes to rest
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset API_AVAILABLE(ios(5.0));
// called on finger up if the user dragged. decelerate is true if it will continue moving afterwards
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate;
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView; // called on finger up as we are moving
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView; // called when scroll view grinds to a halt
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView; // called when setContentOffset/scrollRectVisible:animated: finishes. not called if not animating
- (nullable UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView; // return a view that will be scaled. if delegate returns nil, nothing happens
- (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(nullable UIView *)view API_AVAILABLE(ios(3.2)); // called before the scroll view begins zooming its content
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(nullable UIView *)view atScale:(CGFloat)scale; // scale between minimum and maximum. called after any 'bounce' animations
- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView; // return a yes if you want to scroll to the top. if not defined, assumes YES
- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView; // called when scrolling animation finished. may be called immediately if already at top
/* Also see -[UIScrollView adjustedContentInsetDidChange]
*/
- (void)scrollViewDidChangeAdjustedContentInset:(UIScrollView *)scrollView API_AVAILABLE(ios(11.0), tvos(11.0));
- (nullable NSString *)accessibilityScrollStatusForScrollView:(UIScrollView *)scrollView;
// If an object adopting this protocol responds to this method, the system will try sending it before sending its non-attributed version.
- (nullable NSAttributedString *)accessibilityAttributedScrollStatusForScrollView:(UIScrollView *)scrollView API_AVAILABLE(ios(11.0), tvos(11.0));
@end
NS_ASSUME_NONNULL_END
@@ -25,7 +25,7 @@ public func attachmentDefaultTopInset(layout: ContainerViewLayout?) -> CGFloat {
}
}
final class AttachmentContainer: ASDisplayNode, UIGestureRecognizerDelegate {
final class AttachmentContainer: ASDisplayNode, ASGestureRecognizerDelegate {
let wrappingNode: ASDisplayNode
let clipNode: ASDisplayNode
let container: NavigationContainer
@@ -112,7 +112,7 @@ final class AttachmentContainer: ASDisplayNode, UIGestureRecognizerDelegate {
super.didLoad()
let panRecognizer = UIPanGestureRecognizer(target: self, action: #selector(self.panGesture(_:)))
panRecognizer.delegate = self
panRecognizer.delegate = self.wrappedGestureRecognizerDelegate
panRecognizer.delaysTouchesBegan = false
panRecognizer.cancelsTouchesInView = true
self.panGestureRecognizer = panRecognizer
@@ -680,7 +680,7 @@ private final class MainButtonNode: HighlightTrackingButtonNode {
}
}
final class AttachmentPanel: ASDisplayNode, UIScrollViewDelegate {
final class AttachmentPanel: ASDisplayNode, ASScrollViewDelegate {
private let context: AccountContext
private let isScheduledMessages: Bool
private var presentationData: PresentationData
@@ -1026,7 +1026,7 @@ final class AttachmentPanel: ASDisplayNode, UIScrollViewDelegate {
self.containerNode.layer.cornerCurve = .continuous
}
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.scrollNode.view.showsHorizontalScrollIndicator = false
self.scrollNode.view.showsVerticalScrollIndicator = false
@@ -92,7 +92,7 @@ enum BotCheckoutInfoControllerStatus {
case verifying
}
final class BotCheckoutInfoControllerNode: ViewControllerTracingNode, UIScrollViewDelegate {
final class BotCheckoutInfoControllerNode: ViewControllerTracingNode, ASScrollViewDelegate {
private let context: AccountContext
private weak var navigationBar: NavigationBar?
private let invoice: BotPaymentInvoice
@@ -244,7 +244,7 @@ final class BotCheckoutInfoControllerNode: ViewControllerTracingNode, UIScrollVi
self.scrollNode.view.alwaysBounceVertical = true
self.scrollNode.view.showsVerticalScrollIndicator = false
self.scrollNode.view.showsHorizontalScrollIndicator = false
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.addSubnode(self.scrollNode)
@@ -41,7 +41,7 @@ private final class BotCheckoutNativeCardEntryScrollerNode: ASDisplayNode {
}
}
final class BotCheckoutNativeCardEntryControllerNode: ViewControllerTracingNode, UIScrollViewDelegate {
final class BotCheckoutNativeCardEntryControllerNode: ViewControllerTracingNode, ASScrollViewDelegate {
private let context: AccountContext
private weak var navigationBar: NavigationBar?
private let provider: BotCheckoutNativeCardEntryController.Provider
@@ -183,7 +183,7 @@ final class BotCheckoutNativeCardEntryControllerNode: ViewControllerTracingNode,
self.scrollNode.view.alwaysBounceVertical = true
self.scrollNode.view.showsVerticalScrollIndicator = false
self.scrollNode.view.showsHorizontalScrollIndicator = false
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.addSubnode(self.scrollNode)
@@ -191,7 +191,7 @@ class StackItemContainerNode: ASDisplayNode {
}
}
public class StackContainerNode: ASDisplayNode, UIScrollViewDelegate, UIGestureRecognizerDelegate {
public class StackContainerNode: ASDisplayNode, ASScrollViewDelegate, ASGestureRecognizerDelegate {
private let scrollNode: ASScrollNode
private var nodes: [StackItemContainerNode]
@@ -222,11 +222,11 @@ public class StackContainerNode: ASDisplayNode, UIScrollViewDelegate, UIGestureR
self.scrollNode.view.contentInsetAdjustmentBehavior = .never
}
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.scrollNode.view.alwaysBounceVertical = true
let deleteGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(didPanToDelete(gestureRecognizer:)))
deleteGestureRecognizer.delegate = self
deleteGestureRecognizer.delegate = self.wrappedGestureRecognizerDelegate
deleteGestureRecognizer.delaysTouchesBegan = true
self.scrollNode.view.addGestureRecognizer(deleteGestureRecognizer)
self.deleteGestureRecognizer = deleteGestureRecognizer
@@ -975,7 +975,7 @@ private func monthMetadata(calendar: Calendar, for baseDate: Date, currentYear:
}
public final class CalendarMessageScreen: ViewController {
private final class Node: ViewControllerTracingNode, UIScrollViewDelegate {
private final class Node: ViewControllerTracingNode, ASScrollViewDelegate {
struct SelectionState {
var dayRange: ClosedRange<Int32>?
}
@@ -1173,7 +1173,7 @@ public final class CalendarMessageScreen: ViewController {
self.backgroundColor = self.presentationData.theme.list.plainBackgroundColor
self.scrollView.delegate = self
self.scrollView.delegate = self.wrappedScrollViewDelegate
self.addSubnode(self.contextGestureContainerNode)
self.contextGestureContainerNode.view.addSubview(self.scrollView)
@@ -44,7 +44,7 @@ public enum ChatListContainerNodeFilter: Equatable {
}
}
public final class ChatListContainerNode: ASDisplayNode, UIGestureRecognizerDelegate {
public final class ChatListContainerNode: ASDisplayNode, ASGestureRecognizerDelegate {
private let context: AccountContext
private weak var controller: ChatListControllerImpl?
let location: ChatListControllerLocation
@@ -481,7 +481,7 @@ public final class ChatListContainerNode: ASDisplayNode, UIGestureRecognizerDele
return [.rightEdge]
}
}, edgeWidth: .widthMultiplier(factor: 1.0 / 6.0, min: 22.0, max: 80.0))
panRecognizer.delegate = self
panRecognizer.delegate = self.wrappedGestureRecognizerDelegate
panRecognizer.delaysTouchesBegan = false
panRecognizer.cancelsTouchesInView = true
self.panRecognizer = panRecognizer
@@ -1009,7 +1009,7 @@ public final class ChatListContainerNode: ASDisplayNode, UIGestureRecognizerDele
}
}
final class ChatListControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
final class ChatListControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
private let context: AccountContext
private let location: ChatListControllerLocation
private var presentationData: PresentationData
@@ -1199,7 +1199,7 @@ final class ChatListControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
let directions: InteractiveTransitionGestureRecognizerDirections = [.rightCenter]
return directions
}, edgeWidth: .widthMultiplier(factor: 1.0 / 6.0, min: 22.0, max: 80.0))
inlineContentPanRecognizer.delegate = self
inlineContentPanRecognizer.delegate = self.wrappedGestureRecognizerDelegate
inlineContentPanRecognizer.delaysTouchesBegan = false
inlineContentPanRecognizer.cancelsTouchesInView = true
self.inlineContentPanRecognizer = inlineContentPanRecognizer
@@ -594,7 +594,7 @@ private enum ItemsLayout {
}
}
final class ChatListSearchMediaNode: ASDisplayNode, UIScrollViewDelegate {
final class ChatListSearchMediaNode: ASDisplayNode, ASScrollViewDelegate {
enum ContentType {
case photoOrVideo
case gifs
@@ -664,7 +664,7 @@ final class ChatListSearchMediaNode: ASDisplayNode, UIScrollViewDelegate {
self.scrollNode.view.contentInsetAdjustmentBehavior = .never
}
self.scrollNode.view.scrollsToTop = false
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.addSubnode(self.scrollNode)
self.addSubnode(self.floatingHeaderNode)
@@ -142,7 +142,7 @@ private final class ChatListSearchPendingPane {
}
}
final class ChatListSearchPaneContainerNode: ASDisplayNode, UIGestureRecognizerDelegate {
final class ChatListSearchPaneContainerNode: ASDisplayNode, ASGestureRecognizerDelegate {
private let context: AccountContext
private let animationCache: AnimationCache
private let animationRenderer: MultiAnimationRenderer
@@ -234,7 +234,7 @@ final class ChatListSearchPaneContainerNode: ASDisplayNode, UIGestureRecognizerD
}
return [.left, .right]
})
panRecognizer.delegate = self
panRecognizer.delegate = self.wrappedGestureRecognizerDelegate
panRecognizer.delaysTouchesBegan = false
panRecognizer.cancelsTouchesInView = true
self.view.addGestureRecognizer(panRecognizer)
@@ -156,7 +156,7 @@ private final class InfoPageNode: ASDisplayNode {
}
}
class ChatListArchiveInfoItemNode: ListViewItemNode, UIScrollViewDelegate {
class ChatListArchiveInfoItemNode: ListViewItemNode, ASScrollViewDelegate {
private var item: ChatListArchiveInfoItem?
private let scrollNode: ASScrollNode
@@ -187,7 +187,7 @@ class ChatListArchiveInfoItemNode: ListViewItemNode, UIScrollViewDelegate {
self.scrollNode.view.showsHorizontalScrollIndicator = false
self.scrollNode.view.isPagingEnabled = true
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.pageControlNode.setPage(0.0)
}
@@ -1808,11 +1808,8 @@ public final class ChatListNode: ListView {
self.present?(UndoOverlayController(presentationData: presentationData, content: .info(title: nil, text: presentationData.strings.ChatList_BirthdayInSettingsInfo, timeout: 5.0, customUndoText: nil), elevatedLayout: false, action: { _ in
return true
}))
case let .birthdayPremiumGift(peers, _):
let peerIds = peers.sorted { lhs, rhs in
return lhs.id < rhs.id
}
let _ = ApplicationSpecificNotice.setDismissedBirthdayPremiumGifts(accountManager: self.context.sharedContext.accountManager, values: peerIds.map { $0.id.toInt64() }).start()
case .birthdayPremiumGift:
let _ = self.context.engine.notices.dismissServerProvidedSuggestion(suggestion: .todayBirthdays).startStandalone()
self.present?(UndoOverlayController(presentationData: presentationData, content: .info(title: nil, text: presentationData.strings.ChatList_PremiumGiftInSettingsInfo, timeout: 5.0, customUndoText: nil), elevatedLayout: false, action: { _ in
return true
}))
@@ -1909,13 +1906,13 @@ public final class ChatListNode: ListView {
let suggestedChatListNoticeSignal: Signal<ChatListNotice?, NoError> = combineLatest(
context.engine.notices.getServerProvidedSuggestions(),
context.engine.notices.getServerDismissedSuggestions(),
twoStepData,
newSessionReviews(postbox: context.account.postbox),
context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.Birthday(id: context.account.peerId)),
context.account.stateManager.contactBirthdays,
ApplicationSpecificNotice.dismissedBirthdayPremiumGifts(accountManager: context.sharedContext.accountManager)
context.account.stateManager.contactBirthdays
)
|> mapToSignal { suggestions, configuration, newSessionReviews, birthday, birthdays, dismissedBirthdayPeerIds -> Signal<ChatListNotice?, NoError> in
|> mapToSignal { suggestions, dismissedSuggestions, configuration, newSessionReviews, birthday, birthdays -> Signal<ChatListNotice?, NoError> in
if let newSessionReview = newSessionReviews.first {
return .single(.reviewLogin(newSessionReview: newSessionReview, totalCount: newSessionReviews.count))
}
@@ -1945,6 +1942,10 @@ public final class ChatListNode: ListView {
return lhs < rhs
}
if dismissedSuggestions.contains(.todayBirthdays) {
todayBirthdayPeerIds = []
}
if suggestions.contains(.setupBirthday) && birthday == nil {
return .single(.setupBirthday)
} else if suggestions.contains(.xmasPremiumGift) {
@@ -1989,7 +1990,7 @@ public final class ChatListNode: ListView {
return nil
}
}
} else if !todayBirthdayPeerIds.isEmpty && todayBirthdayPeerIds.map({ $0.toInt64() }) != dismissedBirthdayPeerIds {
} else if !todayBirthdayPeerIds.isEmpty {
return context.engine.data.get(
EngineDataMap(todayBirthdayPeerIds.map(TelegramEngine.EngineData.Item.Peer.Peer.init(id:)))
)
@@ -155,7 +155,7 @@ private final class ActionSheetItemNode: ASDisplayNode {
}
}
final class ChatSendMessageActionSheetControllerNode: ViewControllerTracingNode, UIScrollViewDelegate {
final class ChatSendMessageActionSheetControllerNode: ViewControllerTracingNode, ASScrollViewDelegate {
private let context: AccountContext
private var presentationData: PresentationData
private let sourceSendButton: ASDisplayNode
@@ -382,7 +382,7 @@ final class ChatSendMessageActionSheetControllerNode: ViewControllerTracingNode,
self.scrollNode.view.showsVerticalScrollIndicator = false
self.scrollNode.view.delaysContentTouches = false
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.scrollNode.view.alwaysBounceVertical = true
if #available(iOSApplicationExtension 11.0, iOS 11.0, *) {
self.scrollNode.view.contentInsetAdjustmentBehavior = .never
@@ -387,7 +387,7 @@ public final class ReactionListContextMenuContent: ContextControllerItemsContent
private static let readIconImage: UIImage? = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/MenuReadIcon"), color: .white)?.withRenderingMode(.alwaysTemplate)
private static let reactionIconImage: UIImage? = generateTintedImage(image: UIImage(bundleImageName: "Chat/Message/MenuReactionIcon"), color: .white)?.withRenderingMode(.alwaysTemplate)
private final class ReactionsTabNode: ASDisplayNode, UIScrollViewDelegate {
private final class ReactionsTabNode: ASDisplayNode, ASScrollViewDelegate {
private final class ItemNode: HighlightTrackingButtonNode {
let context: AccountContext
let displayReadTimestamps: Bool
@@ -868,7 +868,7 @@ public final class ReactionListContextMenuContent: ContextControllerItemsContent
super.init()
self.addSubnode(self.scrollNode)
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.clipsToBounds = true
@@ -1101,7 +1101,7 @@ public final class ReactionListContextMenuContent: ContextControllerItemsContent
}
}
final class ItemsNode: ASDisplayNode, ContextControllerItemsNode, UIGestureRecognizerDelegate {
final class ItemsNode: ASDisplayNode, ContextControllerItemsNode, ASGestureRecognizerDelegate {
private let context: AccountContext
private let displayReadTimestamps: Bool
private let availableReactions: AvailableReactions?
@@ -1266,7 +1266,7 @@ public final class ReactionListContextMenuContent: ContextControllerItemsContent
}
return [.left, .right]
})
panRecognizer.delegate = self
panRecognizer.delegate = self.wrappedGestureRecognizerDelegate
self.view.addGestureRecognizer(panRecognizer)
}
@@ -44,7 +44,7 @@ private final class ContextControllerContentSourceImpl: ContextControllerContent
}
}
final class ContactsControllerNode: ASDisplayNode, UIGestureRecognizerDelegate {
final class ContactsControllerNode: ASDisplayNode, ASGestureRecognizerDelegate {
let contactListNode: ContactListNode
private let context: AccountContext
@@ -247,7 +247,7 @@ func convertFrame(_ frame: CGRect, from fromView: UIView, to toView: UIView) ->
return targetWindowFrame
}
final class ContextControllerNode: ViewControllerTracingNode, UIScrollViewDelegate {
final class ContextControllerNode: ViewControllerTracingNode, ASScrollViewDelegate {
private weak var controller: ContextController?
private var presentationData: PresentationData
@@ -408,7 +408,7 @@ final class ContextControllerNode: ViewControllerTracingNode, UIScrollViewDelega
self?.updateLayout()
}
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
if blurBackground {
self.view.addSubview(self.effectView)
@@ -1101,7 +1101,7 @@ final class ContextControllerActionsStackNode: ASDisplayNode {
case additional
}
final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelegate {
final class NavigationContainer: ASDisplayNode, ASGestureRecognizerDelegate {
let backgroundNode: NavigationBackgroundNode
let parentShadowNode: ASImageNode
@@ -1136,7 +1136,7 @@ final class ContextControllerActionsStackNode: ASDisplayNode {
let _ = strongSelf
return [.right]
})
panRecognizer.delegate = self
panRecognizer.delegate = self.wrappedGestureRecognizerDelegate
self.view.addGestureRecognizer(panRecognizer)
self.panRecognizer = panRecognizer
}
@@ -110,7 +110,7 @@ private extension ContextControllerTakeViewInfo.ContainingItem {
}
}
final class ContextControllerExtractedPresentationNode: ASDisplayNode, ContextControllerPresentationNode, UIScrollViewDelegate {
final class ContextControllerExtractedPresentationNode: ASDisplayNode, ContextControllerPresentationNode, ASScrollViewDelegate {
enum ContentSource {
case location(ContextLocationContentSource)
case reference(ContextReferenceContentSource)
@@ -339,7 +339,7 @@ final class ContextControllerExtractedPresentationNode: ASDisplayNode, ContextCo
//self.addSubnode(self.contentRectDebugNode)
#endif
self.scroller.delegate = self
self.scroller.delegate = self.wrappedScrollViewDelegate
self.dismissTapNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dismissTapGesture(_:))))
@@ -133,7 +133,7 @@ private func cancelContextGestures(view: UIView) {
}
}
public final class PinchSourceContainerNode: ASDisplayNode, UIGestureRecognizerDelegate {
public final class PinchSourceContainerNode: ASDisplayNode, ASGestureRecognizerDelegate {
public let contentNode: ASDisplayNode
public var contentRect: CGRect = CGRect()
private(set) var naturalContentFrame: CGRect?
@@ -4,7 +4,7 @@ import SwiftSignalKit
private let containerInsets = UIEdgeInsets(top: 10.0, left: 10.0, bottom: 10.0, right: 10.0)
final class ActionSheetControllerNode: ASDisplayNode, UIScrollViewDelegate {
final class ActionSheetControllerNode: ASDisplayNode, ASScrollViewDelegate {
var theme: ActionSheetControllerTheme {
didSet {
self.itemGroupsContainerNode.theme = self.theme
@@ -64,7 +64,7 @@ final class ActionSheetControllerNode: ASDisplayNode, UIScrollViewDelegate {
super.init()
self.scrollView.delegate = self
self.scrollView.delegate = self.wrappedScrollViewDelegate
self.addSubnode(self.scrollNode)
@@ -1,7 +1,7 @@
import UIKit
import AsyncDisplayKit
final class ActionSheetItemGroupNode: ASDisplayNode, UIScrollViewDelegate {
final class ActionSheetItemGroupNode: ASDisplayNode, ASScrollViewDelegate {
private let theme: ActionSheetControllerTheme
private let centerDimView: UIImageView
@@ -60,7 +60,7 @@ final class ActionSheetItemGroupNode: ASDisplayNode, UIScrollViewDelegate {
self.view.addSubview(self.bottomDimView)
self.view.addSubview(self.trailingDimView)
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.clippingNode.view.addSubview(self.backgroundEffectView)
self.clippingNode.addSubnode(self.scrollNode)
@@ -0,0 +1,213 @@
import Foundation
import UIKit
import ObjectiveC
import AsyncDisplayKit
private var ASGestureRecognizerDelegateKey: Int?
private var ASScrollViewDelegateKey: Int?
private final class WrappedGestureRecognizerDelegate: NSObject, UIGestureRecognizerDelegate {
private weak var target: ASGestureRecognizerDelegate?
init(target: ASGestureRecognizerDelegate) {
self.target = target
super.init()
}
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
guard let target = self.target else {
return true
}
return target.gestureRecognizerShouldBegin?(gestureRecognizer) ?? true
}
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
guard let target = self.target else {
return false
}
return target.gestureRecognizer?(gestureRecognizer, shouldRecognizeSimultaneouslyWith: otherGestureRecognizer) ?? false
}
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRequireFailureOf otherGestureRecognizer: UIGestureRecognizer) -> Bool {
guard let target = self.target else {
return false
}
return target.gestureRecognizer?(gestureRecognizer, shouldRequireFailureOf: otherGestureRecognizer) ?? false
}
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldBeRequiredToFailBy otherGestureRecognizer: UIGestureRecognizer) -> Bool {
guard let target = self.target else {
return false
}
return target.gestureRecognizer?(gestureRecognizer, shouldBeRequiredToFailBy: otherGestureRecognizer) ?? false
}
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool {
guard let target = self.target else {
return true
}
return target.gestureRecognizer?(gestureRecognizer, shouldReceive: touch) ?? true
}
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive press: UIPress) -> Bool {
guard let target = self.target else {
return true
}
return target.gestureRecognizer?(gestureRecognizer, shouldReceive: press) ?? true
}
@available(iOS 13.4, *)
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive event: UIEvent) -> Bool {
guard let target = self.target else {
return true
}
return target.gestureRecognizer?(gestureRecognizer, shouldReceive: event) ?? true
}
}
public extension ASGestureRecognizerDelegate {
var wrappedGestureRecognizerDelegate: UIGestureRecognizerDelegate {
if let delegate = objc_getAssociatedObject(self, &ASGestureRecognizerDelegateKey) as? WrappedGestureRecognizerDelegate {
return delegate
} else {
let delegate = WrappedGestureRecognizerDelegate(target: self)
objc_setAssociatedObject(self, &ASGestureRecognizerDelegateKey, delegate, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
return delegate
}
}
}
private final class WrappedScrollViewDelegate: NSObject, UIScrollViewDelegate, UIScrollViewAccessibilityDelegate {
private weak var target: ASScrollViewDelegate?
init(target: ASScrollViewDelegate) {
self.target = target
super.init()
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
guard let target = self.target else {
return
}
target.scrollViewDidScroll?(scrollView)
}
func scrollViewDidZoom(_ scrollView: UIScrollView) {
guard let target = self.target else {
return
}
target.scrollViewDidZoom?(scrollView)
}
func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {
guard let target = self.target else {
return
}
target.scrollViewWillBeginDragging?(scrollView)
}
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
guard let target = self.target else {
return
}
target.scrollViewWillEndDragging?(scrollView, withVelocity: velocity, targetContentOffset: targetContentOffset)
}
func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {
guard let target = self.target else {
return
}
target.scrollViewDidEndDragging?(scrollView, willDecelerate: decelerate)
}
func scrollViewWillBeginDecelerating(_ scrollView: UIScrollView) {
guard let target = self.target else {
return
}
target.scrollViewWillBeginDecelerating?(scrollView)
}
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
guard let target = self.target else {
return
}
target.scrollViewDidEndDecelerating?(scrollView)
}
func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
guard let target = self.target else {
return
}
target.scrollViewDidEndScrollingAnimation?(scrollView)
}
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
guard let target = self.target else {
return nil
}
return target.viewForZooming?(in: scrollView)
}
func scrollViewWillBeginZooming(_ scrollView: UIScrollView, with view: UIView?) {
guard let target = self.target else {
return
}
target.scrollViewWillBeginZooming?(scrollView, with: view)
}
func scrollViewDidEndZooming(_ scrollView: UIScrollView, with view: UIView?, atScale scale: CGFloat) {
guard let target = self.target else {
return
}
target.scrollViewDidEndZooming?(scrollView, with: view, atScale: scale)
}
func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool {
guard let target = self.target else {
return true
}
return target.scrollViewShouldScroll?(toTop: scrollView) ?? true
}
func scrollViewDidScrollToTop(_ scrollView: UIScrollView) {
guard let target = self.target else {
return
}
target.scrollViewDidScroll?(toTop: scrollView)
}
func scrollViewDidChangeAdjustedContentInset(_ scrollView: UIScrollView) {
guard let target = self.target else {
return
}
target.scrollViewDidChangeAdjustedContentInset?(scrollView)
}
func accessibilityScrollStatus(for scrollView: UIScrollView) -> String? {
guard let target = self.target else {
return nil
}
return target.accessibilityScrollStatus?(for: scrollView)
}
func accessibilityAttributedScrollStatus(for scrollView: UIScrollView) -> NSAttributedString? {
guard let target = self.target else {
return nil
}
return target.accessibilityAttributedScrollStatus?(for: scrollView)
}
}
public extension ASScrollViewDelegate {
var wrappedScrollViewDelegate: UIScrollViewDelegate & UIScrollViewAccessibilityDelegate {
if let delegate = objc_getAssociatedObject(self, &ASScrollViewDelegateKey) as? WrappedScrollViewDelegate {
return delegate
} else {
let delegate = WrappedScrollViewDelegate(target: self)
objc_setAssociatedObject(self, &ASScrollViewDelegateKey, delegate, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
return delegate
}
}
}
+2 -2
View File
@@ -207,7 +207,7 @@ private struct WrappedGridItemNode: Hashable {
}
}
open class GridNode: GridNodeScroller, UIScrollViewDelegate {
open class GridNode: GridNodeScroller, ASScrollViewDelegate {
public private(set) var gridLayout = GridNodeLayout(size: CGSize(), insets: UIEdgeInsets(), preloadSize: 0.0, type: .fixed(itemSize: CGSize(), fillWidth: nil, lineSpacing: 0.0, itemSpacing: nil))
private var firstIndexInSectionOffset: Int = 0
public private(set) var items: [GridItem] = []
@@ -257,7 +257,7 @@ open class GridNode: GridNodeScroller, UIScrollViewDelegate {
self.scrollView.showsVerticalScrollIndicator = false
self.scrollView.showsHorizontalScrollIndicator = false
self.scrollView.scrollsToTop = false
self.scrollView.delegate = self
self.scrollView.delegate = self.wrappedScrollViewDelegate
}
required public init?(coder aDecoder: NSCoder) {
@@ -32,7 +32,7 @@ public class GridNodeScrollerView: UIScrollView {
}
}
open class GridNodeScroller: ASDisplayNode, UIGestureRecognizerDelegate {
open class GridNodeScroller: ASDisplayNode, ASGestureRecognizerDelegate {
public var scrollView: UIScrollView {
return self.view as! UIScrollView
}
+4 -4
View File
@@ -149,7 +149,7 @@ private func cancelContextGestures(view: UIView) {
}
}
open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGestureRecognizerDelegate {
open class ListView: ASDisplayNode, ASScrollViewDelegate, ASGestureRecognizerDelegate {
public struct ScrollingIndicatorState {
public struct Item {
public var index: Int
@@ -494,13 +494,13 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
self.scroller.alwaysBounceVertical = true
self.scroller.contentSize = CGSize(width: 0.0, height: infiniteScrollSize * 2.0)
self.scroller.isHidden = true
self.scroller.delegate = self
self.scroller.delegate = self.wrappedScrollViewDelegate
self.view.addSubview(self.scroller)
self.scroller.panGestureRecognizer.cancelsTouchesInView = true
self.view.addGestureRecognizer(self.scroller.panGestureRecognizer)
let trackingRecognizer = UIPanGestureRecognizer(target: self, action: #selector(self.trackingGesture(_:)))
trackingRecognizer.delegate = self
trackingRecognizer.delegate = self.wrappedGestureRecognizerDelegate
trackingRecognizer.cancelsTouchesInView = false
self.view.addGestureRecognizer(trackingRecognizer)
@@ -534,7 +534,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.tapGesture(_:)))
tapGestureRecognizer.isEnabled = false
tapGestureRecognizer.delegate = self
tapGestureRecognizer.delegate = self.wrappedGestureRecognizerDelegate
self.view.addGestureRecognizer(tapGestureRecognizer)
self.tapGestureRecognizer = tapGestureRecognizer
@@ -3,7 +3,7 @@ import UIKit
import AsyncDisplayKit
import SwiftSignalKit
public final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelegate {
public final class NavigationContainer: ASDisplayNode, ASGestureRecognizerDelegate {
private final class Child {
let value: ViewController
var layout: ContainerViewLayout
@@ -151,7 +151,7 @@ public final class NavigationContainer: ASDisplayNode, UIGestureRecognizerDelega
if #available(iOS 13.4, *) {
panRecognizer.allowedScrollTypesMask = .continuous
}
panRecognizer.delegate = self
panRecognizer.delegate = self.wrappedGestureRecognizerDelegate
panRecognizer.delaysTouchesBegan = false
panRecognizer.cancelsTouchesInView = true
self.panRecognizer = panRecognizer
@@ -4,7 +4,7 @@ import AsyncDisplayKit
import SwiftSignalKit
import UIKitRuntimeUtils
final class NavigationModalContainer: ASDisplayNode, UIScrollViewDelegate, UIGestureRecognizerDelegate {
final class NavigationModalContainer: ASDisplayNode, ASScrollViewDelegate, ASGestureRecognizerDelegate {
private var theme: NavigationControllerTheme
let isFlat: Bool
@@ -89,7 +89,7 @@ final class NavigationModalContainer: ASDisplayNode, UIScrollViewDelegate, UIGes
}
self.scrollNode.view.delaysContentTouches = false
self.scrollNode.view.clipsToBounds = false
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
let panRecognizer = InteractiveTransitionGestureRecognizer(target: self, action: #selector(self.panGesture(_:)), allowedDirections: { [weak self] _ in
guard let strongSelf = self, !strongSelf.isDismissed else {
@@ -109,7 +109,7 @@ final class NavigationModalContainer: ASDisplayNode, UIScrollViewDelegate, UIGes
panRecognizer.isEnabled = false
}
}
panRecognizer.delegate = self
panRecognizer.delegate = self.wrappedGestureRecognizerDelegate
panRecognizer.delaysTouchesBegan = false
panRecognizer.cancelsTouchesInView = true
if !self.isFlat {
@@ -312,7 +312,7 @@ final class NavigationModalContainer: ASDisplayNode, UIScrollViewDelegate, UIGes
func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
}
func scrollViewShouldScrollToTop(_ scrollView: UIScrollView) -> Bool {
func scrollViewShouldScroll(toTop scrollView: UIScrollView) -> Bool {
return false
}
@@ -123,7 +123,7 @@ class CaptionScrollWrapperNode: ASDisplayNode {
final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScrollViewDelegate {
final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, ASScrollViewDelegate {
private let context: AccountContext
private var presentationData: PresentationData
private var theme: PresentationTheme
@@ -638,7 +638,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll
override func didLoad() {
super.didLoad()
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.scrollNode.view.showsVerticalScrollIndicator = false
let backwardLongPressGestureRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(self.seekBackwardLongPress(_:)))
@@ -6,7 +6,7 @@ import Postbox
import SwipeToDismissGesture
import AccountContext
open class GalleryControllerNode: ASDisplayNode, UIScrollViewDelegate, UIGestureRecognizerDelegate {
open class GalleryControllerNode: ASDisplayNode, ASScrollViewDelegate, ASGestureRecognizerDelegate {
public var statusBar: StatusBar?
public var navigationBar: NavigationBar? {
didSet {
@@ -143,7 +143,7 @@ open class GalleryControllerNode: ASDisplayNode, UIScrollViewDelegate, UIGesture
self.scrollView.alwaysBounceHorizontal = false
self.scrollView.alwaysBounceVertical = false
self.scrollView.clipsToBounds = false
self.scrollView.delegate = self
self.scrollView.delegate = self.wrappedScrollViewDelegate
self.scrollView.scrollsToTop = false
self.view.addSubview(self.scrollView)
@@ -76,7 +76,7 @@ public struct GalleryPagerTransaction {
}
}
public final class GalleryPagerNode: ASDisplayNode, UIScrollViewDelegate, UIGestureRecognizerDelegate {
public final class GalleryPagerNode: ASDisplayNode, ASScrollViewDelegate, ASGestureRecognizerDelegate {
private let pageGap: CGFloat
private let disableTapNavigation: Bool
@@ -142,7 +142,7 @@ public final class GalleryPagerNode: ASDisplayNode, UIScrollViewDelegate, UIGest
self.scrollView.alwaysBounceHorizontal = !pageGap.isZero
self.scrollView.bounces = !pageGap.isZero
self.scrollView.isPagingEnabled = true
self.scrollView.delegate = self
self.scrollView.delegate = self.wrappedScrollViewDelegate
self.scrollView.clipsToBounds = false
self.scrollView.scrollsToTop = false
self.scrollView.delaysContentTouches = false
@@ -167,7 +167,7 @@ public final class GalleryPagerNode: ASDisplayNode, UIScrollViewDelegate, UIGest
super.didLoad()
let recognizer = TapLongTapOrDoubleTapGestureRecognizer(target: self, action: #selector(self.tapLongTapOrDoubleTapGesture(_:)))
recognizer.delegate = self
recognizer.delegate = self.wrappedGestureRecognizerDelegate
self.tapRecognizer = recognizer
recognizer.tapActionAtPoint = { [weak self] point in
guard let strongSelf = self, strongSelf.pagingEnabled else {
@@ -48,7 +48,7 @@ private final class GalleryThumbnailItemNode: ASDisplayNode {
}
}
public final class GalleryThumbnailContainerNode: ASDisplayNode, UIScrollViewDelegate {
public final class GalleryThumbnailContainerNode: ASDisplayNode, ASScrollViewDelegate {
public let groupId: Int64
private let scrollNode: ASScrollNode
@@ -69,7 +69,7 @@ public final class GalleryThumbnailContainerNode: ASDisplayNode, UIScrollViewDel
super.init()
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.scrollNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.tapGesture(_:))))
self.scrollNode.view.showsHorizontalScrollIndicator = false
self.scrollNode.view.showsVerticalScrollIndicator = false
@@ -3,7 +3,7 @@ import UIKit
import Display
import AsyncDisplayKit
open class ZoomableContentGalleryItemNode: GalleryItemNode, UIScrollViewDelegate {
open class ZoomableContentGalleryItemNode: GalleryItemNode, ASScrollViewDelegate {
public let scrollNode: ASScrollNode
private var containerLayout: ContainerViewLayout?
@@ -34,7 +34,7 @@ open class ZoomableContentGalleryItemNode: GalleryItemNode, UIScrollViewDelegate
super.init()
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.scrollNode.view.showsVerticalScrollIndicator = false
self.scrollNode.view.showsHorizontalScrollIndicator = false
self.scrollNode.view.clipsToBounds = false
@@ -48,7 +48,7 @@ private struct StickerPackPreviewGridTransaction {
}
}
final class ImportStickerPackControllerNode: ViewControllerTracingNode, UIScrollViewDelegate {
final class ImportStickerPackControllerNode: ViewControllerTracingNode, ASScrollViewDelegate {
private let context: AccountContext
private var presentationData: PresentationData
private var stickerPack: ImportStickerPack?
@@ -194,7 +194,7 @@ final class ImportStickerPackControllerNode: ViewControllerTracingNode, UIScroll
self.dimNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimTapGesture(_:))))
self.addSubnode(self.dimNode)
self.wrappingScrollNode.view.delegate = self
self.wrappingScrollNode.view.delegate = self.wrappedScrollViewDelegate
self.addSubnode(self.wrappingScrollNode)
self.wrappingScrollNode.addSubnode(self.cancelButtonNode)
@@ -18,7 +18,7 @@ import UndoUI
import ContextUI
import TranslateUI
final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate {
final class InstantPageControllerNode: ASDisplayNode, ASScrollViewDelegate {
private weak var controller: InstantPageController?
private let context: AccountContext
private var settings: InstantPagePresentationSettings?
@@ -137,7 +137,7 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate {
self.scrollNode.addSubnode(self.scrollNodeFooter)
self.addSubnode(self.navigationBar)
self.scrollNode.view.delaysContentTouches = false
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.navigationBar.back = navigateBack
self.navigationBar.share = { [weak self] in
@@ -10,7 +10,7 @@ import ShareController
import OpenInExternalAppUI
import TelegramUIPreferences
class InstantPageReferenceControllerNode: ViewControllerTracingNode, UIScrollViewDelegate {
class InstantPageReferenceControllerNode: ViewControllerTracingNode, ASScrollViewDelegate {
private let context: AccountContext
private let sourceLocation: InstantPageSourceLocation
private let theme: InstantPageTheme
@@ -84,7 +84,7 @@ class InstantPageReferenceControllerNode: ViewControllerTracingNode, UIScrollVie
self.dimNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimTapGesture(_:))))
self.addSubnode(self.dimNode)
self.wrappingScrollNode.view.delegate = self
self.wrappingScrollNode.view.delegate = self.wrappedScrollViewDelegate
self.addSubnode(self.wrappingScrollNode)
self.wrappingScrollNode.addSubnode(self.contentBackgroundNode)
@@ -63,7 +63,7 @@ private final class InstantPageSlideshowItemNode: ASDisplayNode {
}
}
private final class InstantPageSlideshowPagerNode: ASDisplayNode, UIScrollViewDelegate {
private final class InstantPageSlideshowPagerNode: ASDisplayNode, ASScrollViewDelegate {
private let context: AccountContext
private let sourceLocation: InstantPageSourceLocation
private let theme: InstantPageTheme
@@ -123,7 +123,7 @@ private final class InstantPageSlideshowPagerNode: ASDisplayNode, UIScrollViewDe
self.scrollView.alwaysBounceHorizontal = !pageGap.isZero
self.scrollView.bounces = !pageGap.isZero
self.scrollView.isPagingEnabled = true
self.scrollView.delegate = self
self.scrollView.delegate = self.wrappedScrollViewDelegate
self.scrollView.clipsToBounds = false
self.scrollView.scrollsToTop = false
self.view.addSubview(self.scrollView)
@@ -247,7 +247,7 @@ public final class InviteLinkInviteController: ViewController {
self.controllerNode.containerLayoutUpdated(layout, transition: transition)
}
class Node: ViewControllerTracingNode, UIGestureRecognizerDelegate {
class Node: ViewControllerTracingNode, ASGestureRecognizerDelegate {
private weak var controller: InviteLinkInviteController?
private let context: AccountContext
@@ -574,7 +574,7 @@ public final class InviteLinkInviteController: ViewController {
self.dimNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimTapGesture(_:))))
let panRecognizer = DirectionalPanGestureRecognizer(target: self, action: #selector(self.panGesture(_:)))
panRecognizer.delegate = self
panRecognizer.delegate = self.wrappedGestureRecognizerDelegate
panRecognizer.delaysTouchesBegan = false
panRecognizer.cancelsTouchesInView = true
self.view.addGestureRecognizer(panRecognizer)
@@ -380,7 +380,7 @@ public final class InviteLinkViewController: ViewController {
self.controllerNode.containerLayoutUpdated(layout, transition: transition)
}
class Node: ViewControllerTracingNode, UIGestureRecognizerDelegate {
class Node: ViewControllerTracingNode, ASGestureRecognizerDelegate {
private weak var controller: InviteLinkViewController?
private let context: AccountContext
@@ -855,7 +855,7 @@ public final class InviteLinkViewController: ViewController {
self.dimNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimTapGesture(_:))))
let panRecognizer = DirectionalPanGestureRecognizer(target: self, action: #selector(self.panGesture(_:)))
panRecognizer.delegate = self
panRecognizer.delegate = self.wrappedGestureRecognizerDelegate
panRecognizer.delaysTouchesBegan = false
panRecognizer.cancelsTouchesInView = true
self.view.addGestureRecognizer(panRecognizer)
@@ -58,7 +58,7 @@ public final class ItemListRevealOptionsGestureRecognizer: UIPanGestureRecognize
}
}
open class ItemListRevealOptionsItemNode: ListViewItemNode, UIGestureRecognizerDelegate {
open class ItemListRevealOptionsItemNode: ListViewItemNode, ASGestureRecognizerDelegate {
private var validLayout: (CGSize, CGFloat, CGFloat)?
private var leftRevealNode: ItemListRevealOptionsNode?
@@ -96,13 +96,13 @@ open class ItemListRevealOptionsItemNode: ListViewItemNode, UIGestureRecognizerD
let recognizer = ItemListRevealOptionsGestureRecognizer(target: self, action: #selector(self.revealGesture(_:)))
self.recognizer = recognizer
recognizer.delegate = self
recognizer.delegate = self.wrappedGestureRecognizerDelegate
recognizer.allowAnyDirection = self.allowAnyDirection
self.view.addGestureRecognizer(recognizer)
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.revealTapGesture(_:)))
self.tapRecognizer = tapRecognizer
tapRecognizer.delegate = self
tapRecognizer.delegate = self.wrappedGestureRecognizerDelegate
self.view.addGestureRecognizer(tapRecognizer)
self.view.disablesInteractiveTransitionGestureRecognizer = self.allowAnyDirection
@@ -34,7 +34,7 @@ struct JoinLinkPreviewData {
let isJoined: Bool
}
final class JoinLinkPreviewControllerNode: ViewControllerTracingNode, UIScrollViewDelegate {
final class JoinLinkPreviewControllerNode: ViewControllerTracingNode, ASScrollViewDelegate {
private let context: AccountContext
private var presentationData: PresentationData
@@ -110,7 +110,7 @@ final class JoinLinkPreviewControllerNode: ViewControllerTracingNode, UIScrollVi
self.dimNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimTapGesture(_:))))
self.addSubnode(self.dimNode)
self.wrappingScrollNode.view.delegate = self
self.wrappingScrollNode.view.delegate = self.wrappedScrollViewDelegate
self.addSubnode(self.wrappingScrollNode)
self.cancelButton.addTarget(self, action: #selector(self.cancelButtonPressed), forControlEvents: .touchUpInside)
@@ -9,7 +9,7 @@ import ActivityIndicator
import AccountContext
import ShareController
final class LanguageLinkPreviewControllerNode: ViewControllerTracingNode, UIScrollViewDelegate {
final class LanguageLinkPreviewControllerNode: ViewControllerTracingNode, ASScrollViewDelegate {
private let context: AccountContext
private var presentationData: PresentationData
@@ -121,7 +121,7 @@ final class LanguageLinkPreviewControllerNode: ViewControllerTracingNode, UIScro
self.dimNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimTapGesture(_:))))
self.addSubnode(self.dimNode)
self.wrappingScrollNode.view.delegate = self
self.wrappingScrollNode.view.delegate = self.wrappedScrollViewDelegate
self.addSubnode(self.wrappingScrollNode)
self.cancelButtonNode.setTitle(self.presentationData.strings.Common_Cancel, with: Font.medium(20.0), with: self.presentationData.theme.actionSheet.standardActionTextColor, for: .normal)
@@ -19,6 +19,7 @@
@property (nonatomic, assign) bool displayEdges;
@property (nonatomic, assign) bool useLinesForPositions;
@property (nonatomic, assign) bool markPositions;
@property (nonatomic, readonly) bool knobStartedDragging;
@@ -42,6 +42,7 @@ const CGFloat TGPhotoEditorSliderViewInternalMargin = 7.0f;
_value = _startValue;
_dotSize = 10.5f;
_minimumUndottedValue = -1;
_markPositions = true;
_lineSize = TGPhotoEditorSliderViewLineSize;
_knobPadding = TGPhotoEditorSliderViewInternalMargin;
@@ -214,6 +215,12 @@ const CGFloat TGPhotoEditorSliderViewInternalMargin = 7.0f;
{
for (NSInteger i = 0; i < self.positionsCount; i++)
{
if (!self.markPositions) {
if (i != 0 && i != self.positionsCount - 1) {
continue;
}
}
if (self.useLinesForPositions) {
CGSize lineSize = CGSizeMake(4.0, 12.0);
CGRect lineRect = CGRectMake(margin - lineSize.width / 2.0f + totalLength / (self.positionsCount - 1) * i, (sideLength - lineSize.height) / 2, lineSize.width, lineSize.height);
@@ -169,7 +169,7 @@ private var smallUnitValues: [Int32] = {
return values
}()
class LocationDistancePickerScreenNode: ViewControllerTracingNode, UIScrollViewDelegate, UIPickerViewDataSource, UIPickerViewDelegate {
class LocationDistancePickerScreenNode: ViewControllerTracingNode, ASScrollViewDelegate, UIPickerViewDataSource, UIPickerViewDelegate {
private let context: AccountContext
private let controllerStyle: LocationDistancePickerScreenStyle
private var presentationData: PresentationData
@@ -277,7 +277,7 @@ class LocationDistancePickerScreenNode: ViewControllerTracingNode, UIScrollViewD
self.dimNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimTapGesture(_:))))
self.addSubnode(self.dimNode)
self.wrappingScrollNode.view.delegate = self
self.wrappingScrollNode.view.delegate = self.wrappedScrollViewDelegate
self.addSubnode(self.wrappingScrollNode)
self.wrappingScrollNode.addSubnode(self.backgroundNode)
@@ -14,7 +14,7 @@ struct MediaGroupItem {
}
final class MediaGroupsContextMenuContent: ContextControllerItemsContent {
private final class GroupsListNode: ASDisplayNode, UIScrollViewDelegate {
private final class GroupsListNode: ASDisplayNode, ASScrollViewDelegate {
private final class ItemNode: HighlightTrackingButtonNode {
let context: AccountContext
let highlightBackgroundNode: ASDisplayNode
@@ -170,7 +170,7 @@ final class MediaGroupsContextMenuContent: ContextControllerItemsContent {
super.init()
self.addSubnode(self.scrollNode)
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.clipsToBounds = true
}
@@ -210,7 +210,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
var dismissAll: () -> Void = { }
private class Node: ViewControllerTracingNode, UIGestureRecognizerDelegate {
private class Node: ViewControllerTracingNode, ASGestureRecognizerDelegate {
enum DisplayMode {
case all
case selected
@@ -440,7 +440,7 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
} else {
let selectionGesture = MediaPickerGridSelectionGesture<TGMediaSelectableItem>()
selectionGesture.delegate = self
selectionGesture.delegate = self.wrappedGestureRecognizerDelegate
selectionGesture.began = { [weak self] in
self?.controller?.cancelPanGesture()
}
@@ -496,7 +496,7 @@ private class MessageBackgroundNode: ASDisplayNode {
}
}
final class MediaPickerSelectedListNode: ASDisplayNode, UIScrollViewDelegate, UIGestureRecognizerDelegate {
final class MediaPickerSelectedListNode: ASDisplayNode, ASScrollViewDelegate, ASGestureRecognizerDelegate {
private let context: AccountContext
private let persistentItems: Bool
@@ -539,7 +539,7 @@ final class MediaPickerSelectedListNode: ASDisplayNode, UIScrollViewDelegate, UI
self.scrollNode.view.contentInsetAdjustmentBehavior = .never
}
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.scrollNode.view.panGestureRecognizer.cancelsTouchesInView = true
self.scrollNode.view.showsVerticalScrollIndicator = false
@@ -63,7 +63,7 @@ public func parseMediaPlayerChapters(_ string: NSAttributedString) -> [MediaPlay
return chapters
}
private final class MediaPlayerScrubbingNodeButton: ASDisplayNode, UIGestureRecognizerDelegate {
private final class MediaPlayerScrubbingNodeButton: ASDisplayNode, ASGestureRecognizerDelegate {
var beginScrubbing: (() -> Void)?
var endScrubbing: ((Bool) -> Void)?
var updateScrubbing: ((CGFloat, Double) -> Void)?
@@ -83,7 +83,7 @@ private final class MediaPlayerScrubbingNodeButton: ASDisplayNode, UIGestureReco
self.view.disablesInteractiveTransitionGestureRecognizer = true
let gestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(self.panGesture(_:)))
gestureRecognizer.delegate = self
gestureRecognizer.delegate = self.wrappedGestureRecognizerDelegate
self.view.addGestureRecognizer(gestureRecognizer)
}
@@ -105,7 +105,7 @@ private enum FilteredItemNeighbor {
case item(FormControllerItem)
}
public class FormControllerNode<InitParams, InnerState: FormControllerInnerState>: ViewControllerTracingNode, UIScrollViewDelegate {
public class FormControllerNode<InitParams, InnerState: FormControllerInnerState>: ViewControllerTracingNode, ASScrollViewDelegate {
private typealias InternalState = FormControllerInternalState<InnerState>
typealias State = FormControllerState<InnerState>
typealias Entry = InnerState.Entry
@@ -142,7 +142,7 @@ public class FormControllerNode<InitParams, InnerState: FormControllerInnerState
self.scrollNode.backgroundColor = nil
self.scrollNode.isOpaque = false
self.scrollNode.delegate = self
self.scrollNode.delegate = self.wrappedScrollViewDelegate
self.addSubnode(self.scrollNode)
self.scrollNode.view.delaysContentTouches = true
@@ -1,6 +1,7 @@
import Foundation
import UIKit
import AsyncDisplayKit
import Display
final class FormControllerScrollerNodeView: UIScrollView {
weak var target: FormControllerScrollerNode?
@@ -46,7 +47,7 @@ final class FormControllerScrollerNodeView: UIScrollView {
}
}
final class FormControllerScrollerNode: ASDisplayNode, UIScrollViewDelegate {
final class FormControllerScrollerNode: ASDisplayNode, ASScrollViewDelegate {
override var view: FormControllerScrollerNodeView {
return super.view as! FormControllerScrollerNodeView
}
@@ -66,7 +67,7 @@ final class FormControllerScrollerNode: ASDisplayNode, UIScrollViewDelegate {
override func didLoad() {
super.didLoad()
self.view.delegate = self
self.view.delegate = self.wrappedScrollViewDelegate
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
@@ -6,7 +6,7 @@ import TelegramPresentationData
import ItemListUI
import PresentationDataUtils
class FormEditableBlockItemNode<Item: FormControllerItem>: ASDisplayNode, FormControllerItemNode, FormBlockItemNodeProto, UIGestureRecognizerDelegate {
class FormEditableBlockItemNode<Item: FormControllerItem>: ASDisplayNode, FormControllerItemNode, FormBlockItemNodeProto, ASGestureRecognizerDelegate {
private let topSeparatorInset: FormBlockItemInset
private let highlightedBackgroundNode: ASDisplayNode
@@ -1268,7 +1268,7 @@ private final class TwoFactorDataInputTextNode: ASDisplayNode, UITextFieldDelega
}
}
private final class TwoFactorDataInputScreenNode: ViewControllerTracingNode, UIScrollViewDelegate {
private final class TwoFactorDataInputScreenNode: ViewControllerTracingNode, ASScrollViewDelegate {
private var presentationData: PresentationData
private let mode: TwoFactorDataInputMode
private let action: () -> Void
@@ -1818,7 +1818,7 @@ private final class TwoFactorDataInputScreenNode: ViewControllerTracingNode, UIS
if #available(iOSApplicationExtension 11.0, iOS 11.0, *) {
self.scrollNode.view.contentInsetAdjustmentBehavior = .never
}
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
@@ -854,7 +854,7 @@ public func createGiveawayController(context: AccountContext, updatedPresentatio
let expiryDate = calendar.date(byAdding: .day, value: 3, to: calendar.date(from: components)!)!
let expiryTime = Int32(expiryDate.timeIntervalSince1970)
let minDate = currentTime + 60 * 30
let minDate = currentTime + 60 * 1
let maxDate = currentTime + context.userLimits.maxGiveawayPeriodSeconds
let initialState: CreateGiveawayControllerState = CreateGiveawayControllerState(mode: .giveaway, subscriptions: initialSubscriptions, time: expiryTime)
@@ -1099,7 +1099,9 @@ public func createGiveawayController(context: AccountContext, updatedPresentatio
let quantity: Int32
switch state.mode {
case .giveaway:
purpose = .giveaway(boostPeer: peerId, additionalPeerIds: state.channels.filter { $0 != peerId }, countries: state.countries, onlyNewSubscribers: state.onlyNewEligible, showWinners: state.showWinners, prizeDescription: state.prizeDescription.isEmpty ? nil : state.prizeDescription, randomId: Int64.random(in: .min ..< .max), untilDate: state.time, currency: currency, amount: amount)
let currentTime = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
let untilDate = max(state.time, currentTime + 60)
purpose = .giveaway(boostPeer: peerId, additionalPeerIds: state.channels.filter { $0 != peerId }, countries: state.countries, onlyNewSubscribers: state.onlyNewEligible, showWinners: state.showWinners, prizeDescription: state.prizeDescription.isEmpty ? nil : state.prizeDescription, randomId: Int64.random(in: .min ..< .max), untilDate: untilDate, currency: currency, amount: amount)
quantity = selectedProduct.giftOption.storeQuantity
case .gift:
purpose = .giftCode(peerIds: state.peers, boostPeer: peerId, currency: currency, amount: amount)
@@ -1596,7 +1596,7 @@ public class PremiumBoostLevelsScreen: ViewController {
case features
}
final class Node: ViewControllerTracingNode, UIScrollViewDelegate, UIGestureRecognizerDelegate {
final class Node: ViewControllerTracingNode, ASScrollViewDelegate, ASGestureRecognizerDelegate {
private var presentationData: PresentationData
private weak var controller: PremiumBoostLevelsScreen?
@@ -1727,7 +1727,7 @@ public class PremiumBoostLevelsScreen: ViewController {
super.didLoad()
let panRecognizer = UIPanGestureRecognizer(target: self, action: #selector(self.panGesture(_:)))
panRecognizer.delegate = self
panRecognizer.delegate = self.wrappedGestureRecognizerDelegate
panRecognizer.delaysTouchesBegan = false
panRecognizer.cancelsTouchesInView = true
self.panGestureRecognizer = panRecognizer
@@ -1463,6 +1463,7 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent {
var isPremium: Bool?
var peer: EnginePeer?
var adsEnabled = false
private var disposable: Disposable?
private(set) var configuration = PremiumIntroConfiguration.defaultValue
@@ -1470,6 +1471,7 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent {
private var stickersDisposable: Disposable?
private var newPerksDisposable: Disposable?
private var preloadDisposableSet = DisposableSet()
private var adsEnabledDisposable: Disposable?
var price: String? {
return self.products?.first(where: { $0.id == self.selectedProductId })?.price
@@ -1491,6 +1493,8 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent {
}
}
var cachedChevronImage: (UIImage, PresentationTheme)?
init(
context: AccountContext,
source: PremiumSource,
@@ -1581,6 +1585,15 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent {
self.newPerks = newPerks
self.updated()
})
self.adsEnabledDisposable = (context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.AdsEnabled(id: context.account.peerId))
|> deliverOnMainQueue).start(next: { [weak self] adsEnabled in
guard let self else {
return
}
self.adsEnabled = adsEnabled
self.updated()
})
}
deinit {
@@ -1588,6 +1601,7 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent {
self.preloadDisposableSet.dispose()
self.stickersDisposable?.dispose()
self.newPerksDisposable?.dispose()
self.adsEnabledDisposable?.dispose()
}
private var updatedPeerStatus: PeerEmojiStatus?
@@ -1653,6 +1667,7 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent {
let optionsSection = Child(SectionGroupComponent.self)
let businessSection = Child(ListSectionComponent.self)
let moreBusinessSection = Child(ListSectionComponent.self)
let adsSettingsSection = Child(ListSectionComponent.self)
let perksSection = Child(ListSectionComponent.self)
let infoBackground = Child(RoundedRectangle.self)
let infoTitle = Child(MultilineTextComponent.self)
@@ -2464,6 +2479,94 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent {
size.height += 23.0
}
let termsFont = Font.regular(13.0)
let boldTermsFont = Font.semibold(13.0)
let italicTermsFont = Font.italic(13.0)
let boldItalicTermsFont = Font.semiboldItalic(13.0)
let monospaceTermsFont = Font.monospace(13.0)
let termsTextColor = environment.theme.list.freeTextColor
let termsMarkdownAttributes = MarkdownAttributes(body: MarkdownAttributeSet(font: termsFont, textColor: termsTextColor), bold: MarkdownAttributeSet(font: termsFont, textColor: termsTextColor), link: MarkdownAttributeSet(font: termsFont, textColor: environment.theme.list.itemAccentColor), linkAttribute: { contents in
return (TelegramTextAttributes.URL, contents)
})
let layoutAdsSettings = {
size.height += 8.0
var adsSettingsItems: [AnyComponentWithIdentity<Empty>] = []
adsSettingsItems.append(AnyComponentWithIdentity(id: 0, component: AnyComponent(ListActionItemComponent(
theme: environment.theme,
title: AnyComponent(VStack([
AnyComponentWithIdentity(id: AnyHashable(0), component: AnyComponent(MultilineTextComponent(
text: .plain(NSAttributedString(
string: environment.strings.Business_DontHideAds,
font: Font.regular(presentationData.listsFontSize.baseDisplaySize),
textColor: environment.theme.list.itemPrimaryTextColor
)),
maximumNumberOfLines: 1
))),
], alignment: .left, spacing: 2.0)),
accessory: .toggle(ListActionItemComponent.Toggle(style: .regular, isOn: state.adsEnabled, action: { [weak state] value in
let _ = accountContext.engine.accountData.updateAdMessagesEnabled(enabled: value).startStandalone()
state?.updated(transition: .immediate)
})),
action: nil
))))
let adsInfoString = NSMutableAttributedString(attributedString: parseMarkdownIntoAttributedString(environment.strings.Business_AdsInfo, attributes: termsMarkdownAttributes, textAlignment: .natural
))
if state.cachedChevronImage == nil || state.cachedChevronImage?.1 !== theme {
state.cachedChevronImage = (generateTintedImage(image: UIImage(bundleImageName: "Contact List/SubtitleArrow"), color: environment.theme.list.itemAccentColor)!, theme)
}
if let range = adsInfoString.string.range(of: ">"), let chevronImage = state.cachedChevronImage?.0 {
adsInfoString.addAttribute(.attachment, value: chevronImage, range: NSRange(range, in: adsInfoString.string))
}
let controller = environment.controller
let adsInfoTapActionImpl: ([NSAttributedString.Key: Any]) -> Void = { _ in
if let controller = controller() as? PremiumIntroScreen {
controller.context.sharedContext.openExternalUrl(context: controller.context, urlContext: .generic, url: environment.strings.Business_AdsInfo_URL, forceExternal: true, presentationData: controller.context.sharedContext.currentPresentationData.with({$0}), navigationController: nil, dismissInput: {})
}
}
let adsSettingsSection = adsSettingsSection.update(
component: ListSectionComponent(
theme: environment.theme,
header: AnyComponent(MultilineTextComponent(
text: .plain(NSAttributedString(
string: strings.Business_AdsTitle.uppercased(),
font: Font.regular(presentationData.listsFontSize.itemListBaseHeaderFontSize),
textColor: environment.theme.list.freeTextColor
)),
maximumNumberOfLines: 0
)),
footer: AnyComponent(MultilineTextComponent(
text: .plain(adsInfoString),
maximumNumberOfLines: 0,
highlightColor: environment.theme.list.itemAccentColor.withAlphaComponent(0.2),
highlightAction: { attributes in
if let _ = attributes[NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)] {
return NSAttributedString.Key(rawValue: TelegramTextAttributes.URL)
} else {
return nil
}
},
tapAction: { attributes, _ in
adsInfoTapActionImpl(attributes)
}
)),
items: adsSettingsItems
),
environment: {},
availableSize: CGSize(width: availableWidth - sideInsets, height: .greatestFiniteMagnitude),
transition: context.transition
)
context.add(adsSettingsSection
.position(CGPoint(x: availableWidth / 2.0, y: size.height + adsSettingsSection.size.height / 2.0))
.clipsToBounds(true)
.cornerRadius(10.0)
)
size.height += adsSettingsSection.size.height
size.height += 23.0
}
let copyLink = context.component.copyLink
if case .emojiStatus = context.component.source {
layoutPerks()
@@ -2499,6 +2602,7 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent {
layoutBusinessPerks()
if context.component.isPremium == true {
layoutMoreBusinessPerks()
layoutAdsSettings()
}
} else {
layoutPerks()
@@ -2556,17 +2660,7 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent {
)
size.height += infoBackground.size.height
size.height += 6.0
let termsFont = Font.regular(13.0)
let boldTermsFont = Font.semibold(13.0)
let italicTermsFont = Font.italic(13.0)
let boldItalicTermsFont = Font.semiboldItalic(13.0)
let monospaceTermsFont = Font.monospace(13.0)
let termsTextColor = environment.theme.list.freeTextColor
let termsMarkdownAttributes = MarkdownAttributes(body: MarkdownAttributeSet(font: termsFont, textColor: termsTextColor), bold: MarkdownAttributeSet(font: termsFont, textColor: termsTextColor), link: MarkdownAttributeSet(font: termsFont, textColor: environment.theme.list.itemAccentColor), linkAttribute: { contents in
return (TelegramTextAttributes.URL, contents)
})
var isGiftView = false
if case let .gift(fromId, _, _, _) = context.component.source {
if fromId == context.component.context.account.peerId {
@@ -18,7 +18,7 @@ import SolidRoundedButtonNode
import BlurredBackgroundComponent
public class PremiumLimitsListScreen: ViewController {
final class Node: ViewControllerTracingNode, UIScrollViewDelegate, UIGestureRecognizerDelegate {
final class Node: ViewControllerTracingNode, ASScrollViewDelegate, ASGestureRecognizerDelegate {
private var presentationData: PresentationData
private weak var controller: PremiumLimitsListScreen?
@@ -188,7 +188,7 @@ public class PremiumLimitsListScreen: ViewController {
super.didLoad()
let panRecognizer = UIPanGestureRecognizer(target: self, action: #selector(self.panGesture(_:)))
panRecognizer.delegate = self
panRecognizer.delegate = self.wrappedGestureRecognizerDelegate
panRecognizer.delaysTouchesBegan = false
panRecognizer.cancelsTouchesInView = true
self.panGestureRecognizer = panRecognizer
@@ -294,7 +294,7 @@ private final class ReplaceBoostScreenComponent: CombinedComponent {
}
public class ReplaceBoostScreen: ViewController {
final class Node: ViewControllerTracingNode, UIScrollViewDelegate, UIGestureRecognizerDelegate {
final class Node: ViewControllerTracingNode, ASScrollViewDelegate, ASGestureRecognizerDelegate {
private var presentationData: PresentationData
private weak var controller: ReplaceBoostScreen?
@@ -345,7 +345,7 @@ public class ReplaceBoostScreen: ViewController {
super.init()
self.scrollView.delegate = self
self.scrollView.delegate = self.wrappedScrollViewDelegate
self.scrollView.showsVerticalScrollIndicator = false
self.containerView.clipsToBounds = true
@@ -373,7 +373,7 @@ public class ReplaceBoostScreen: ViewController {
super.didLoad()
let panRecognizer = UIPanGestureRecognizer(target: self, action: #selector(self.panGesture(_:)))
panRecognizer.delegate = self
panRecognizer.delegate = self.wrappedGestureRecognizerDelegate
panRecognizer.delaysTouchesBegan = false
panRecognizer.cancelsTouchesInView = true
self.panGestureRecognizer = panRecognizer
@@ -279,7 +279,7 @@ private class StickerNode: ASDisplayNode {
}
}
private class StickersCarouselNode: ASDisplayNode, UIScrollViewDelegate {
private class StickersCarouselNode: ASDisplayNode, ASScrollViewDelegate {
private let context: AccountContext
private let stickers: [TelegramMediaFile]
private let tapAction: () -> Void
@@ -331,7 +331,7 @@ private class StickersCarouselNode: ASDisplayNode, UIScrollViewDelegate {
override func didLoad() {
super.didLoad()
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.scrollNode.view.showsHorizontalScrollIndicator = false
self.scrollNode.view.showsVerticalScrollIndicator = false
self.scrollNode.view.canCancelContentTouches = true
@@ -387,7 +387,7 @@ private final class FrameNode: ASDisplayNode {
}
}
private final class QrCodeScanScreenNode: ViewControllerTracingNode, UIScrollViewDelegate {
private final class QrCodeScanScreenNode: ViewControllerTracingNode, ASScrollViewDelegate {
private let context: AccountContext
private var presentationData: PresentationData
private weak var controller: QrCodeScanScreen?
@@ -182,7 +182,7 @@ public final class QrCodeScreen: ViewController {
self.controllerNode.containerLayoutUpdated(layout, navigationBarHeight: self.navigationLayout(layout: layout).navigationFrame.maxY, transition: transition)
}
class Node: ViewControllerTracingNode, UIScrollViewDelegate {
class Node: ViewControllerTracingNode, ASScrollViewDelegate {
private let context: AccountContext
private let subject: QrCodeScreen.Subject
private var presentationData: PresentationData
@@ -279,7 +279,7 @@ public final class QrCodeScreen: ViewController {
self.dimNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimTapGesture(_:))))
self.addSubnode(self.dimNode)
self.wrappingScrollNode.view.delegate = self
self.wrappingScrollNode.view.delegate = self.wrappedScrollViewDelegate
self.addSubnode(self.wrappingScrollNode)
self.wrappingScrollNode.addSubnode(self.backgroundNode)
@@ -241,7 +241,7 @@ private final class TitleLabelView: UIView {
}
}
public final class ReactionContextNode: ASDisplayNode, UIScrollViewDelegate {
public final class ReactionContextNode: ASDisplayNode, ASScrollViewDelegate {
private struct ItemLayout {
var itemSize: CGFloat
var visibleItemCount: Int
@@ -590,7 +590,7 @@ public final class ReactionContextNode: ASDisplayNode, UIScrollViewDelegate {
self.addSubnode(self.backgroundNode)
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.addSubnode(self.contentContainer)
self.addSubnode(self.previewingItemContainer)
@@ -83,7 +83,7 @@ private class SegmentedControlItemNode: HighlightTrackingButtonNode {
}
}
public final class SegmentedControlNode: ASDisplayNode, UIGestureRecognizerDelegate {
public final class SegmentedControlNode: ASDisplayNode, ASGestureRecognizerDelegate {
private var theme: SegmentedControlTheme
private var _items: [SegmentedControlItem]
private var _selectedIndex: Int = 0
@@ -224,7 +224,7 @@ public final class SegmentedControlNode: ASDisplayNode, UIGestureRecognizerDeleg
self.view.disablesInteractiveTransitionGestureRecognizer = true
let gestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(self.panGesture(_:)))
gestureRecognizer.delegate = self
gestureRecognizer.delegate = self.wrappedGestureRecognizerDelegate
self.view.addGestureRecognizer(gestureRecognizer)
self.gestureRecognizer = gestureRecognizer
}
@@ -29,7 +29,7 @@ private func generateMaskImage(color: UIColor) -> UIImage? {
})
}
private final class BubbleSettingsControllerNode: ASDisplayNode, UIScrollViewDelegate {
private final class BubbleSettingsControllerNode: ASDisplayNode, ASScrollViewDelegate {
private let context: AccountContext
private var presentationThemeSettings: PresentationThemeSettings
private var presentationData: PresentationData
@@ -132,7 +132,7 @@ private final class BubbleSettingsControllerNode: ASDisplayNode, UIScrollViewDel
self.scrollNode.view.disablesInteractiveTransitionGestureRecognizer = true
self.scrollNode.view.showsHorizontalScrollIndicator = false
self.scrollNode.view.isPagingEnabled = true
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.scrollNode.view.alwaysBounceHorizontal = false
}
@@ -153,7 +153,7 @@ final class RecentSessionScreen: ViewController {
}
}
private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDelegate {
private class RecentSessionScreenNode: ViewControllerTracingNode, ASScrollViewDelegate {
private let context: AccountContext
private var presentationData: PresentationData
private weak var controller: RecentSessionScreen?
@@ -459,7 +459,7 @@ private class RecentSessionScreenNode: ViewControllerTracingNode, UIScrollViewDe
self.addSubnode(self.dimNode)
self.wrappingScrollNode.view.delegate = self
self.wrappingScrollNode.view.delegate = self.wrappedScrollViewDelegate
self.addSubnode(self.wrappingScrollNode)
self.wrappingScrollNode.addSubnode(self.backgroundNode)
@@ -31,7 +31,7 @@ private func generateMaskImage(color: UIColor) -> UIImage? {
})
}
private final class TextSizeSelectionControllerNode: ASDisplayNode, UIScrollViewDelegate {
private final class TextSizeSelectionControllerNode: ASDisplayNode, ASScrollViewDelegate {
private let context: AccountContext
private var presentationThemeSettings: PresentationThemeSettings
private var presentationData: PresentationData
@@ -173,7 +173,7 @@ private final class TextSizeSelectionControllerNode: ASDisplayNode, UIScrollView
self.scrollNode.view.disablesInteractiveTransitionGestureRecognizer = true
self.scrollNode.view.showsHorizontalScrollIndicator = false
self.scrollNode.view.isPagingEnabled = true
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.pageControlNode.setPage(0.0)
}
@@ -31,7 +31,7 @@ private func generateMaskImage(color: UIColor) -> UIImage? {
})
}
final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate {
final class ThemePreviewControllerNode: ASDisplayNode, ASScrollViewDelegate {
private let context: AccountContext
private var previewTheme: PresentationTheme
private var presentationData: PresentationData
@@ -318,7 +318,7 @@ final class ThemePreviewControllerNode: ASDisplayNode, UIScrollViewDelegate {
self.scrollNode.view.disablesInteractiveTransitionGestureRecognizer = true
self.scrollNode.view.showsHorizontalScrollIndicator = false
self.scrollNode.view.isPagingEnabled = true
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.pageControlNode.setPage(0.0)
}
@@ -296,7 +296,7 @@ private final class ShareContentInfoView: UIView {
}
}
final class ShareControllerNode: ViewControllerTracingNode, UIScrollViewDelegate {
final class ShareControllerNode: ViewControllerTracingNode, ASScrollViewDelegate {
private weak var controller: ShareController?
private let environment: ShareControllerEnvironment
private var context: ShareControllerAccountContext?
@@ -624,7 +624,7 @@ final class ShareControllerNode: ViewControllerTracingNode, UIScrollViewDelegate
self.dimNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimTapGesture(_:))))
self.addSubnode(self.dimNode)
self.wrappingScrollNode.view.delegate = self
self.wrappingScrollNode.view.delegate = self.wrappedScrollViewDelegate
self.addSubnode(self.wrappingScrollNode)
self.cancelButtonNode.setTitle(self.presentationData.strings.Common_Cancel, with: Font.medium(20.0), with: self.presentationData.theme.actionSheet.standardActionTextColor, for: .normal)
@@ -338,7 +338,7 @@ public final class SparseItemGrid: ASDisplayNode {
}
}
private final class Viewport: ASDisplayNode, UIScrollViewDelegate {
private final class Viewport: ASDisplayNode, ASScrollViewDelegate {
final class VisibleItem: SparseItemGridDisplayItem {
let layer: SparseItemGridLayer?
let view: SparseItemGridView?
@@ -527,7 +527,7 @@ public final class SparseItemGrid: ASDisplayNode {
self.anchorPoint = CGPoint()
self.scrollView.delegate = self
self.scrollView.delegate = self.wrappedScrollViewDelegate
self.view.addSubview(self.scrollView)
}
@@ -46,7 +46,7 @@ private struct StickerPackPreviewGridTransaction {
}
}
final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrollViewDelegate {
final class StickerPackPreviewControllerNode: ViewControllerTracingNode, ASScrollViewDelegate {
private let context: AccountContext
private let openShare: (() -> Void)?
private var presentationData: PresentationData
@@ -152,7 +152,7 @@ final class StickerPackPreviewControllerNode: ViewControllerTracingNode, UIScrol
self.dimNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimTapGesture(_:))))
self.addSubnode(self.dimNode)
self.wrappingScrollNode.view.delegate = self
self.wrappingScrollNode.view.delegate = self.wrappedScrollViewDelegate
self.addSubnode(self.wrappingScrollNode)
self.wrappingScrollNode.addSubnode(self.cancelButtonNode)
@@ -9,7 +9,7 @@ import TelegramPresentationData
import AccountContext
import StickerResources
final class StickerPreviewControllerNode: ASDisplayNode, UIScrollViewDelegate {
final class StickerPreviewControllerNode: ASDisplayNode, ASScrollViewDelegate {
private let context: AccountContext
private let presentationData: PresentationData
+2 -2
View File
@@ -316,7 +316,7 @@ final class TabBarNodeItem {
}
}
class TabBarNode: ASDisplayNode, UIGestureRecognizerDelegate {
class TabBarNode: ASDisplayNode, ASGestureRecognizerDelegate {
var tabBarItems: [TabBarNodeItem] = [] {
didSet {
self.reloadTabBarItems()
@@ -389,7 +389,7 @@ class TabBarNode: ASDisplayNode, UIGestureRecognizerDelegate {
super.didLoad()
let recognizer = TapLongTapOrDoubleTapGestureRecognizer(target: self, action: #selector(self.tapLongTapOrDoubleTapGesture(_:)))
recognizer.delegate = self
recognizer.delegate = self.wrappedGestureRecognizerDelegate
recognizer.tapActionAtPoint = { _ in
return .keepWithSingleTap
}
+3 -6
View File
@@ -198,8 +198,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[1605510357] = { return Api.ChatAdminRights.parse_chatAdminRights($0) }
dict[-219353309] = { return Api.ChatAdminWithInvites.parse_chatAdminWithInvites($0) }
dict[-1626209256] = { return Api.ChatBannedRights.parse_chatBannedRights($0) }
dict[1153455271] = { return Api.ChatFull.parse_channelFull($0) }
dict[-908914376] = { return Api.ChatFull.parse_chatFull($0) }
dict[-1146407795] = { return Api.ChatFull.parse_channelFull($0) }
dict[640893467] = { return Api.ChatFull.parse_chatFull($0) }
dict[-840897472] = { return Api.ChatInvite.parse_chatInvite($0) }
dict[1516793212] = { return Api.ChatInvite.parse_chatInviteAlready($0) }
dict[1634294960] = { return Api.ChatInvite.parse_chatInvitePeek($0) }
@@ -857,9 +857,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1239335713] = { return Api.ShippingOption.parse_shippingOption($0) }
dict[-2010155333] = { return Api.SimpleWebViewResult.parse_simpleWebViewResultUrl($0) }
dict[-425595208] = { return Api.SmsJob.parse_smsJob($0) }
dict[-313293833] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) }
dict[-1611532106] = { return Api.SponsoredMessage.parse_sponsoredMessage($0) }
dict[1124938064] = { return Api.SponsoredMessageReportOption.parse_sponsoredMessageReportOption($0) }
dict[1035529315] = { return Api.SponsoredWebPage.parse_sponsoredWebPage($0) }
dict[-884757282] = { return Api.StatsAbsValueAndPrev.parse_statsAbsValueAndPrev($0) }
dict[-1237848657] = { return Api.StatsDateRangeDays.parse_statsDateRangeDays($0) }
dict[-1901828938] = { return Api.StatsGraph.parse_statsGraph($0) }
@@ -1932,8 +1931,6 @@ public extension Api {
_1.serialize(buffer, boxed)
case let _1 as Api.SponsoredMessageReportOption:
_1.serialize(buffer, boxed)
case let _1 as Api.SponsoredWebPage:
_1.serialize(buffer, boxed)
case let _1 as Api.StatsAbsValueAndPrev:
_1.serialize(buffer, boxed)
case let _1 as Api.StatsDateRangeDays:
+81 -109
View File
@@ -477,31 +477,27 @@ public extension Api {
}
}
public extension Api {
indirect enum SponsoredMessage: TypeConstructorDescription {
case sponsoredMessage(flags: Int32, randomId: Buffer, fromId: Api.Peer?, chatInvite: Api.ChatInvite?, chatInviteHash: String?, channelPost: Int32?, startParam: String?, webpage: Api.SponsoredWebPage?, app: Api.BotApp?, message: String, entities: [Api.MessageEntity]?, buttonText: String?, sponsorInfo: String?, additionalInfo: String?)
enum SponsoredMessage: TypeConstructorDescription {
case sponsoredMessage(flags: Int32, randomId: Buffer, url: String, title: String, message: String, entities: [Api.MessageEntity]?, photo: Api.Photo?, buttonText: String, sponsorInfo: String?, additionalInfo: String?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .sponsoredMessage(let flags, let randomId, let fromId, let chatInvite, let chatInviteHash, let channelPost, let startParam, let webpage, let app, let message, let entities, let buttonText, let sponsorInfo, let additionalInfo):
case .sponsoredMessage(let flags, let randomId, let url, let title, let message, let entities, let photo, let buttonText, let sponsorInfo, let additionalInfo):
if boxed {
buffer.appendInt32(-313293833)
buffer.appendInt32(-1611532106)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeBytes(randomId, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 3) != 0 {fromId!.serialize(buffer, true)}
if Int(flags) & Int(1 << 4) != 0 {chatInvite!.serialize(buffer, true)}
if Int(flags) & Int(1 << 4) != 0 {serializeString(chatInviteHash!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 2) != 0 {serializeInt32(channelPost!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 0) != 0 {serializeString(startParam!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 9) != 0 {webpage!.serialize(buffer, true)}
if Int(flags) & Int(1 << 10) != 0 {app!.serialize(buffer, true)}
serializeString(url, buffer: buffer, boxed: false)
serializeString(title, buffer: buffer, boxed: false)
serializeString(message, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 1) != 0 {buffer.appendInt32(481674261)
buffer.appendInt32(Int32(entities!.count))
for item in entities! {
item.serialize(buffer, true)
}}
if Int(flags) & Int(1 << 11) != 0 {serializeString(buttonText!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 6) != 0 {photo!.serialize(buffer, true)}
serializeString(buttonText, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 7) != 0 {serializeString(sponsorInfo!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 8) != 0 {serializeString(additionalInfo!, buffer: buffer, boxed: false)}
break
@@ -510,8 +506,8 @@ public extension Api {
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .sponsoredMessage(let flags, let randomId, let fromId, let chatInvite, let chatInviteHash, let channelPost, let startParam, let webpage, let app, let message, let entities, let buttonText, let sponsorInfo, let additionalInfo):
return ("sponsoredMessage", [("flags", flags as Any), ("randomId", randomId as Any), ("fromId", fromId as Any), ("chatInvite", chatInvite as Any), ("chatInviteHash", chatInviteHash as Any), ("channelPost", channelPost as Any), ("startParam", startParam as Any), ("webpage", webpage as Any), ("app", app as Any), ("message", message as Any), ("entities", entities as Any), ("buttonText", buttonText as Any), ("sponsorInfo", sponsorInfo as Any), ("additionalInfo", additionalInfo as Any)])
case .sponsoredMessage(let flags, let randomId, let url, let title, let message, let entities, let photo, let buttonText, let sponsorInfo, let additionalInfo):
return ("sponsoredMessage", [("flags", flags as Any), ("randomId", randomId as Any), ("url", url as Any), ("title", title as Any), ("message", message as Any), ("entities", entities as Any), ("photo", photo as Any), ("buttonText", buttonText as Any), ("sponsorInfo", sponsorInfo as Any), ("additionalInfo", additionalInfo as Any)])
}
}
@@ -520,56 +516,38 @@ public extension Api {
_1 = reader.readInt32()
var _2: Buffer?
_2 = parseBytes(reader)
var _3: Api.Peer?
if Int(_1!) & Int(1 << 3) != 0 {if let signature = reader.readInt32() {
_3 = Api.parse(reader, signature: signature) as? Api.Peer
} }
var _4: Api.ChatInvite?
if Int(_1!) & Int(1 << 4) != 0 {if let signature = reader.readInt32() {
_4 = Api.parse(reader, signature: signature) as? Api.ChatInvite
} }
var _3: String?
_3 = parseString(reader)
var _4: String?
_4 = parseString(reader)
var _5: String?
if Int(_1!) & Int(1 << 4) != 0 {_5 = parseString(reader) }
var _6: Int32?
if Int(_1!) & Int(1 << 2) != 0 {_6 = reader.readInt32() }
var _7: String?
if Int(_1!) & Int(1 << 0) != 0 {_7 = parseString(reader) }
var _8: Api.SponsoredWebPage?
if Int(_1!) & Int(1 << 9) != 0 {if let signature = reader.readInt32() {
_8 = Api.parse(reader, signature: signature) as? Api.SponsoredWebPage
} }
var _9: Api.BotApp?
if Int(_1!) & Int(1 << 10) != 0 {if let signature = reader.readInt32() {
_9 = Api.parse(reader, signature: signature) as? Api.BotApp
} }
var _10: String?
_10 = parseString(reader)
var _11: [Api.MessageEntity]?
_5 = parseString(reader)
var _6: [Api.MessageEntity]?
if Int(_1!) & Int(1 << 1) != 0 {if let _ = reader.readInt32() {
_11 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageEntity.self)
_6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.MessageEntity.self)
} }
var _12: String?
if Int(_1!) & Int(1 << 11) != 0 {_12 = parseString(reader) }
var _13: String?
if Int(_1!) & Int(1 << 7) != 0 {_13 = parseString(reader) }
var _14: String?
if Int(_1!) & Int(1 << 8) != 0 {_14 = parseString(reader) }
var _7: Api.Photo?
if Int(_1!) & Int(1 << 6) != 0 {if let signature = reader.readInt32() {
_7 = Api.parse(reader, signature: signature) as? Api.Photo
} }
var _8: String?
_8 = parseString(reader)
var _9: String?
if Int(_1!) & Int(1 << 7) != 0 {_9 = parseString(reader) }
var _10: String?
if Int(_1!) & Int(1 << 8) != 0 {_10 = parseString(reader) }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = (Int(_1!) & Int(1 << 3) == 0) || _3 != nil
let _c4 = (Int(_1!) & Int(1 << 4) == 0) || _4 != nil
let _c5 = (Int(_1!) & Int(1 << 4) == 0) || _5 != nil
let _c6 = (Int(_1!) & Int(1 << 2) == 0) || _6 != nil
let _c7 = (Int(_1!) & Int(1 << 0) == 0) || _7 != nil
let _c8 = (Int(_1!) & Int(1 << 9) == 0) || _8 != nil
let _c9 = (Int(_1!) & Int(1 << 10) == 0) || _9 != nil
let _c10 = _10 != nil
let _c11 = (Int(_1!) & Int(1 << 1) == 0) || _11 != nil
let _c12 = (Int(_1!) & Int(1 << 11) == 0) || _12 != nil
let _c13 = (Int(_1!) & Int(1 << 7) == 0) || _13 != nil
let _c14 = (Int(_1!) & Int(1 << 8) == 0) || _14 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 {
return Api.SponsoredMessage.sponsoredMessage(flags: _1!, randomId: _2!, fromId: _3, chatInvite: _4, chatInviteHash: _5, channelPost: _6, startParam: _7, webpage: _8, app: _9, message: _10!, entities: _11, buttonText: _12, sponsorInfo: _13, additionalInfo: _14)
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = (Int(_1!) & Int(1 << 1) == 0) || _6 != nil
let _c7 = (Int(_1!) & Int(1 << 6) == 0) || _7 != nil
let _c8 = _8 != nil
let _c9 = (Int(_1!) & Int(1 << 7) == 0) || _9 != nil
let _c10 = (Int(_1!) & Int(1 << 8) == 0) || _10 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 {
return Api.SponsoredMessage.sponsoredMessage(flags: _1!, randomId: _2!, url: _3!, title: _4!, message: _5!, entities: _6, photo: _7, buttonText: _8!, sponsorInfo: _9, additionalInfo: _10)
}
else {
return nil
@@ -618,56 +596,6 @@ public extension Api {
}
}
public extension Api {
enum SponsoredWebPage: TypeConstructorDescription {
case sponsoredWebPage(flags: Int32, url: String, siteName: String, photo: Api.Photo?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .sponsoredWebPage(let flags, let url, let siteName, let photo):
if boxed {
buffer.appendInt32(1035529315)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeString(url, buffer: buffer, boxed: false)
serializeString(siteName, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {photo!.serialize(buffer, true)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .sponsoredWebPage(let flags, let url, let siteName, let photo):
return ("sponsoredWebPage", [("flags", flags as Any), ("url", url as Any), ("siteName", siteName as Any), ("photo", photo as Any)])
}
}
public static func parse_sponsoredWebPage(_ reader: BufferReader) -> SponsoredWebPage? {
var _1: Int32?
_1 = reader.readInt32()
var _2: String?
_2 = parseString(reader)
var _3: String?
_3 = parseString(reader)
var _4: Api.Photo?
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
_4 = Api.parse(reader, signature: signature) as? Api.Photo
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 0) == 0) || _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.SponsoredWebPage.sponsoredWebPage(flags: _1!, url: _2!, siteName: _3!, photo: _4)
}
else {
return nil
}
}
}
}
public extension Api {
enum StatsAbsValueAndPrev: TypeConstructorDescription {
case statsAbsValueAndPrev(current: Double, previous: Double)
@@ -922,3 +850,47 @@ public extension Api {
}
}
public extension Api {
enum StatsGroupTopPoster: TypeConstructorDescription {
case statsGroupTopPoster(userId: Int64, messages: Int32, avgChars: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .statsGroupTopPoster(let userId, let messages, let avgChars):
if boxed {
buffer.appendInt32(-1660637285)
}
serializeInt64(userId, buffer: buffer, boxed: false)
serializeInt32(messages, buffer: buffer, boxed: false)
serializeInt32(avgChars, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .statsGroupTopPoster(let userId, let messages, let avgChars):
return ("statsGroupTopPoster", [("userId", userId as Any), ("messages", messages as Any), ("avgChars", avgChars as Any)])
}
}
public static func parse_statsGroupTopPoster(_ reader: BufferReader) -> StatsGroupTopPoster? {
var _1: Int64?
_1 = reader.readInt64()
var _2: Int32?
_2 = reader.readInt32()
var _3: Int32?
_3 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.StatsGroupTopPoster.statsGroupTopPoster(userId: _1!, messages: _2!, avgChars: _3!)
}
else {
return nil
}
}
}
}
@@ -1,47 +1,3 @@
public extension Api {
enum StatsGroupTopPoster: TypeConstructorDescription {
case statsGroupTopPoster(userId: Int64, messages: Int32, avgChars: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .statsGroupTopPoster(let userId, let messages, let avgChars):
if boxed {
buffer.appendInt32(-1660637285)
}
serializeInt64(userId, buffer: buffer, boxed: false)
serializeInt32(messages, buffer: buffer, boxed: false)
serializeInt32(avgChars, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .statsGroupTopPoster(let userId, let messages, let avgChars):
return ("statsGroupTopPoster", [("userId", userId as Any), ("messages", messages as Any), ("avgChars", avgChars as Any)])
}
}
public static func parse_statsGroupTopPoster(_ reader: BufferReader) -> StatsGroupTopPoster? {
var _1: Int64?
_1 = reader.readInt64()
var _2: Int32?
_2 = reader.readInt32()
var _3: Int32?
_3 = reader.readInt32()
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
if _c1 && _c2 && _c3 {
return Api.StatsGroupTopPoster.statsGroupTopPoster(userId: _1!, messages: _2!, avgChars: _3!)
}
else {
return nil
}
}
}
}
public extension Api {
enum StatsPercentValue: TypeConstructorDescription {
case statsPercentValue(part: Double, total: Double)
+25 -7
View File
@@ -1361,6 +1361,21 @@ public extension Api.functions.account {
})
}
}
public extension Api.functions.account {
static func toggleSponsoredMessages(enabled: Api.Bool) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
let buffer = Buffer()
buffer.appendInt32(-1176919155)
enabled.serialize(buffer, true)
return (FunctionDescription(name: "account.toggleSponsoredMessages", parameters: [("enabled", String(describing: enabled))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
let reader = BufferReader(buffer)
var result: Api.Bool?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.Bool
}
return result
})
}
}
public extension Api.functions.account {
static func toggleUsername(username: String, active: Api.Bool) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
let buffer = Buffer()
@@ -2770,11 +2785,12 @@ public extension Api.functions.channels {
}
}
public extension Api.functions.channels {
static func getChannelRecommendations(channel: Api.InputChannel) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.Chats>) {
static func getChannelRecommendations(flags: Int32, channel: Api.InputChannel?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.Chats>) {
let buffer = Buffer()
buffer.appendInt32(-2085155433)
channel.serialize(buffer, true)
return (FunctionDescription(name: "channels.getChannelRecommendations", parameters: [("channel", String(describing: channel))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.Chats? in
buffer.appendInt32(631707458)
serializeInt32(flags, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 0) != 0 {channel!.serialize(buffer, true)}
return (FunctionDescription(name: "channels.getChannelRecommendations", parameters: [("flags", String(describing: flags)), ("channel", String(describing: channel))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.Chats? in
let reader = BufferReader(buffer)
var result: Api.messages.Chats?
if let signature = reader.readInt32() {
@@ -7816,12 +7832,14 @@ public extension Api.functions.messages {
}
}
public extension Api.functions.messages {
static func setChatAvailableReactions(peer: Api.InputPeer, availableReactions: Api.ChatReactions) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
static func setChatAvailableReactions(flags: Int32, peer: Api.InputPeer, availableReactions: Api.ChatReactions, reactionsLimit: Int32?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
let buffer = Buffer()
buffer.appendInt32(-21928079)
buffer.appendInt32(1511328724)
serializeInt32(flags, buffer: buffer, boxed: false)
peer.serialize(buffer, true)
availableReactions.serialize(buffer, true)
return (FunctionDescription(name: "messages.setChatAvailableReactions", parameters: [("peer", String(describing: peer)), ("availableReactions", String(describing: availableReactions))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(reactionsLimit!, buffer: buffer, boxed: false)}
return (FunctionDescription(name: "messages.setChatAvailableReactions", parameters: [("flags", String(describing: flags)), ("peer", String(describing: peer)), ("availableReactions", String(describing: availableReactions)), ("reactionsLimit", String(describing: reactionsLimit))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
let reader = BufferReader(buffer)
var result: Api.Updates?
if let signature = reader.readInt32() {
+36 -28
View File
@@ -920,14 +920,14 @@ public extension Api {
}
public extension Api {
enum ChatFull: TypeConstructorDescription {
case channelFull(flags: Int32, flags2: Int32, id: Int64, about: String, participantsCount: Int32?, adminsCount: Int32?, kickedCount: Int32?, bannedCount: Int32?, onlineCount: Int32?, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, chatPhoto: Api.Photo, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite?, botInfo: [Api.BotInfo], migratedFromChatId: Int64?, migratedFromMaxId: Int32?, pinnedMsgId: Int32?, stickerset: Api.StickerSet?, availableMinId: Int32?, folderId: Int32?, linkedChatId: Int64?, location: Api.ChannelLocation?, slowmodeSeconds: Int32?, slowmodeNextSendDate: Int32?, statsDc: Int32?, pts: Int32, call: Api.InputGroupCall?, ttlPeriod: Int32?, pendingSuggestions: [String]?, groupcallDefaultJoinAs: Api.Peer?, themeEmoticon: String?, requestsPending: Int32?, recentRequesters: [Int64]?, defaultSendAs: Api.Peer?, availableReactions: Api.ChatReactions?, stories: Api.PeerStories?, wallpaper: Api.WallPaper?, boostsApplied: Int32?, boostsUnrestrict: Int32?, emojiset: Api.StickerSet?)
case chatFull(flags: Int32, id: Int64, about: String, participants: Api.ChatParticipants, chatPhoto: Api.Photo?, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite?, botInfo: [Api.BotInfo]?, pinnedMsgId: Int32?, folderId: Int32?, call: Api.InputGroupCall?, ttlPeriod: Int32?, groupcallDefaultJoinAs: Api.Peer?, themeEmoticon: String?, requestsPending: Int32?, recentRequesters: [Int64]?, availableReactions: Api.ChatReactions?)
case channelFull(flags: Int32, flags2: Int32, id: Int64, about: String, participantsCount: Int32?, adminsCount: Int32?, kickedCount: Int32?, bannedCount: Int32?, onlineCount: Int32?, readInboxMaxId: Int32, readOutboxMaxId: Int32, unreadCount: Int32, chatPhoto: Api.Photo, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite?, botInfo: [Api.BotInfo], migratedFromChatId: Int64?, migratedFromMaxId: Int32?, pinnedMsgId: Int32?, stickerset: Api.StickerSet?, availableMinId: Int32?, folderId: Int32?, linkedChatId: Int64?, location: Api.ChannelLocation?, slowmodeSeconds: Int32?, slowmodeNextSendDate: Int32?, statsDc: Int32?, pts: Int32, call: Api.InputGroupCall?, ttlPeriod: Int32?, pendingSuggestions: [String]?, groupcallDefaultJoinAs: Api.Peer?, themeEmoticon: String?, requestsPending: Int32?, recentRequesters: [Int64]?, defaultSendAs: Api.Peer?, availableReactions: Api.ChatReactions?, reactionsLimit: Int32?, stories: Api.PeerStories?, wallpaper: Api.WallPaper?, boostsApplied: Int32?, boostsUnrestrict: Int32?, emojiset: Api.StickerSet?)
case chatFull(flags: Int32, id: Int64, about: String, participants: Api.ChatParticipants, chatPhoto: Api.Photo?, notifySettings: Api.PeerNotifySettings, exportedInvite: Api.ExportedChatInvite?, botInfo: [Api.BotInfo]?, pinnedMsgId: Int32?, folderId: Int32?, call: Api.InputGroupCall?, ttlPeriod: Int32?, groupcallDefaultJoinAs: Api.Peer?, themeEmoticon: String?, requestsPending: Int32?, recentRequesters: [Int64]?, availableReactions: Api.ChatReactions?, reactionsLimit: Int32?)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .channelFull(let flags, let flags2, let id, let about, let participantsCount, let adminsCount, let kickedCount, let bannedCount, let onlineCount, let readInboxMaxId, let readOutboxMaxId, let unreadCount, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let migratedFromChatId, let migratedFromMaxId, let pinnedMsgId, let stickerset, let availableMinId, let folderId, let linkedChatId, let location, let slowmodeSeconds, let slowmodeNextSendDate, let statsDc, let pts, let call, let ttlPeriod, let pendingSuggestions, let groupcallDefaultJoinAs, let themeEmoticon, let requestsPending, let recentRequesters, let defaultSendAs, let availableReactions, let stories, let wallpaper, let boostsApplied, let boostsUnrestrict, let emojiset):
case .channelFull(let flags, let flags2, let id, let about, let participantsCount, let adminsCount, let kickedCount, let bannedCount, let onlineCount, let readInboxMaxId, let readOutboxMaxId, let unreadCount, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let migratedFromChatId, let migratedFromMaxId, let pinnedMsgId, let stickerset, let availableMinId, let folderId, let linkedChatId, let location, let slowmodeSeconds, let slowmodeNextSendDate, let statsDc, let pts, let call, let ttlPeriod, let pendingSuggestions, let groupcallDefaultJoinAs, let themeEmoticon, let requestsPending, let recentRequesters, let defaultSendAs, let availableReactions, let reactionsLimit, let stories, let wallpaper, let boostsApplied, let boostsUnrestrict, let emojiset):
if boxed {
buffer.appendInt32(1153455271)
buffer.appendInt32(-1146407795)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(flags2, buffer: buffer, boxed: false)
@@ -978,15 +978,16 @@ public extension Api {
}}
if Int(flags) & Int(1 << 29) != 0 {defaultSendAs!.serialize(buffer, true)}
if Int(flags) & Int(1 << 30) != 0 {availableReactions!.serialize(buffer, true)}
if Int(flags2) & Int(1 << 13) != 0 {serializeInt32(reactionsLimit!, buffer: buffer, boxed: false)}
if Int(flags2) & Int(1 << 4) != 0 {stories!.serialize(buffer, true)}
if Int(flags2) & Int(1 << 7) != 0 {wallpaper!.serialize(buffer, true)}
if Int(flags2) & Int(1 << 8) != 0 {serializeInt32(boostsApplied!, buffer: buffer, boxed: false)}
if Int(flags2) & Int(1 << 9) != 0 {serializeInt32(boostsUnrestrict!, buffer: buffer, boxed: false)}
if Int(flags2) & Int(1 << 10) != 0 {emojiset!.serialize(buffer, true)}
break
case .chatFull(let flags, let id, let about, let participants, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let pinnedMsgId, let folderId, let call, let ttlPeriod, let groupcallDefaultJoinAs, let themeEmoticon, let requestsPending, let recentRequesters, let availableReactions):
case .chatFull(let flags, let id, let about, let participants, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let pinnedMsgId, let folderId, let call, let ttlPeriod, let groupcallDefaultJoinAs, let themeEmoticon, let requestsPending, let recentRequesters, let availableReactions, let reactionsLimit):
if boxed {
buffer.appendInt32(-908914376)
buffer.appendInt32(640893467)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt64(id, buffer: buffer, boxed: false)
@@ -1013,16 +1014,17 @@ public extension Api {
serializeInt64(item, buffer: buffer, boxed: false)
}}
if Int(flags) & Int(1 << 18) != 0 {availableReactions!.serialize(buffer, true)}
if Int(flags) & Int(1 << 20) != 0 {serializeInt32(reactionsLimit!, buffer: buffer, boxed: false)}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .channelFull(let flags, let flags2, let id, let about, let participantsCount, let adminsCount, let kickedCount, let bannedCount, let onlineCount, let readInboxMaxId, let readOutboxMaxId, let unreadCount, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let migratedFromChatId, let migratedFromMaxId, let pinnedMsgId, let stickerset, let availableMinId, let folderId, let linkedChatId, let location, let slowmodeSeconds, let slowmodeNextSendDate, let statsDc, let pts, let call, let ttlPeriod, let pendingSuggestions, let groupcallDefaultJoinAs, let themeEmoticon, let requestsPending, let recentRequesters, let defaultSendAs, let availableReactions, let stories, let wallpaper, let boostsApplied, let boostsUnrestrict, let emojiset):
return ("channelFull", [("flags", flags as Any), ("flags2", flags2 as Any), ("id", id as Any), ("about", about as Any), ("participantsCount", participantsCount as Any), ("adminsCount", adminsCount as Any), ("kickedCount", kickedCount as Any), ("bannedCount", bannedCount as Any), ("onlineCount", onlineCount as Any), ("readInboxMaxId", readInboxMaxId as Any), ("readOutboxMaxId", readOutboxMaxId as Any), ("unreadCount", unreadCount as Any), ("chatPhoto", chatPhoto as Any), ("notifySettings", notifySettings as Any), ("exportedInvite", exportedInvite as Any), ("botInfo", botInfo as Any), ("migratedFromChatId", migratedFromChatId as Any), ("migratedFromMaxId", migratedFromMaxId as Any), ("pinnedMsgId", pinnedMsgId as Any), ("stickerset", stickerset as Any), ("availableMinId", availableMinId as Any), ("folderId", folderId as Any), ("linkedChatId", linkedChatId as Any), ("location", location as Any), ("slowmodeSeconds", slowmodeSeconds as Any), ("slowmodeNextSendDate", slowmodeNextSendDate as Any), ("statsDc", statsDc as Any), ("pts", pts as Any), ("call", call as Any), ("ttlPeriod", ttlPeriod as Any), ("pendingSuggestions", pendingSuggestions as Any), ("groupcallDefaultJoinAs", groupcallDefaultJoinAs as Any), ("themeEmoticon", themeEmoticon as Any), ("requestsPending", requestsPending as Any), ("recentRequesters", recentRequesters as Any), ("defaultSendAs", defaultSendAs as Any), ("availableReactions", availableReactions as Any), ("stories", stories as Any), ("wallpaper", wallpaper as Any), ("boostsApplied", boostsApplied as Any), ("boostsUnrestrict", boostsUnrestrict as Any), ("emojiset", emojiset as Any)])
case .chatFull(let flags, let id, let about, let participants, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let pinnedMsgId, let folderId, let call, let ttlPeriod, let groupcallDefaultJoinAs, let themeEmoticon, let requestsPending, let recentRequesters, let availableReactions):
return ("chatFull", [("flags", flags as Any), ("id", id as Any), ("about", about as Any), ("participants", participants as Any), ("chatPhoto", chatPhoto as Any), ("notifySettings", notifySettings as Any), ("exportedInvite", exportedInvite as Any), ("botInfo", botInfo as Any), ("pinnedMsgId", pinnedMsgId as Any), ("folderId", folderId as Any), ("call", call as Any), ("ttlPeriod", ttlPeriod as Any), ("groupcallDefaultJoinAs", groupcallDefaultJoinAs as Any), ("themeEmoticon", themeEmoticon as Any), ("requestsPending", requestsPending as Any), ("recentRequesters", recentRequesters as Any), ("availableReactions", availableReactions as Any)])
case .channelFull(let flags, let flags2, let id, let about, let participantsCount, let adminsCount, let kickedCount, let bannedCount, let onlineCount, let readInboxMaxId, let readOutboxMaxId, let unreadCount, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let migratedFromChatId, let migratedFromMaxId, let pinnedMsgId, let stickerset, let availableMinId, let folderId, let linkedChatId, let location, let slowmodeSeconds, let slowmodeNextSendDate, let statsDc, let pts, let call, let ttlPeriod, let pendingSuggestions, let groupcallDefaultJoinAs, let themeEmoticon, let requestsPending, let recentRequesters, let defaultSendAs, let availableReactions, let reactionsLimit, let stories, let wallpaper, let boostsApplied, let boostsUnrestrict, let emojiset):
return ("channelFull", [("flags", flags as Any), ("flags2", flags2 as Any), ("id", id as Any), ("about", about as Any), ("participantsCount", participantsCount as Any), ("adminsCount", adminsCount as Any), ("kickedCount", kickedCount as Any), ("bannedCount", bannedCount as Any), ("onlineCount", onlineCount as Any), ("readInboxMaxId", readInboxMaxId as Any), ("readOutboxMaxId", readOutboxMaxId as Any), ("unreadCount", unreadCount as Any), ("chatPhoto", chatPhoto as Any), ("notifySettings", notifySettings as Any), ("exportedInvite", exportedInvite as Any), ("botInfo", botInfo as Any), ("migratedFromChatId", migratedFromChatId as Any), ("migratedFromMaxId", migratedFromMaxId as Any), ("pinnedMsgId", pinnedMsgId as Any), ("stickerset", stickerset as Any), ("availableMinId", availableMinId as Any), ("folderId", folderId as Any), ("linkedChatId", linkedChatId as Any), ("location", location as Any), ("slowmodeSeconds", slowmodeSeconds as Any), ("slowmodeNextSendDate", slowmodeNextSendDate as Any), ("statsDc", statsDc as Any), ("pts", pts as Any), ("call", call as Any), ("ttlPeriod", ttlPeriod as Any), ("pendingSuggestions", pendingSuggestions as Any), ("groupcallDefaultJoinAs", groupcallDefaultJoinAs as Any), ("themeEmoticon", themeEmoticon as Any), ("requestsPending", requestsPending as Any), ("recentRequesters", recentRequesters as Any), ("defaultSendAs", defaultSendAs as Any), ("availableReactions", availableReactions as Any), ("reactionsLimit", reactionsLimit as Any), ("stories", stories as Any), ("wallpaper", wallpaper as Any), ("boostsApplied", boostsApplied as Any), ("boostsUnrestrict", boostsUnrestrict as Any), ("emojiset", emojiset as Any)])
case .chatFull(let flags, let id, let about, let participants, let chatPhoto, let notifySettings, let exportedInvite, let botInfo, let pinnedMsgId, let folderId, let call, let ttlPeriod, let groupcallDefaultJoinAs, let themeEmoticon, let requestsPending, let recentRequesters, let availableReactions, let reactionsLimit):
return ("chatFull", [("flags", flags as Any), ("id", id as Any), ("about", about as Any), ("participants", participants as Any), ("chatPhoto", chatPhoto as Any), ("notifySettings", notifySettings as Any), ("exportedInvite", exportedInvite as Any), ("botInfo", botInfo as Any), ("pinnedMsgId", pinnedMsgId as Any), ("folderId", folderId as Any), ("call", call as Any), ("ttlPeriod", ttlPeriod as Any), ("groupcallDefaultJoinAs", groupcallDefaultJoinAs as Any), ("themeEmoticon", themeEmoticon as Any), ("requestsPending", requestsPending as Any), ("recentRequesters", recentRequesters as Any), ("availableReactions", availableReactions as Any), ("reactionsLimit", reactionsLimit as Any)])
}
}
@@ -1125,21 +1127,23 @@ public extension Api {
if Int(_1!) & Int(1 << 30) != 0 {if let signature = reader.readInt32() {
_37 = Api.parse(reader, signature: signature) as? Api.ChatReactions
} }
var _38: Api.PeerStories?
var _38: Int32?
if Int(_2!) & Int(1 << 13) != 0 {_38 = reader.readInt32() }
var _39: Api.PeerStories?
if Int(_2!) & Int(1 << 4) != 0 {if let signature = reader.readInt32() {
_38 = Api.parse(reader, signature: signature) as? Api.PeerStories
_39 = Api.parse(reader, signature: signature) as? Api.PeerStories
} }
var _39: Api.WallPaper?
var _40: Api.WallPaper?
if Int(_2!) & Int(1 << 7) != 0 {if let signature = reader.readInt32() {
_39 = Api.parse(reader, signature: signature) as? Api.WallPaper
_40 = Api.parse(reader, signature: signature) as? Api.WallPaper
} }
var _40: Int32?
if Int(_2!) & Int(1 << 8) != 0 {_40 = reader.readInt32() }
var _41: Int32?
if Int(_2!) & Int(1 << 9) != 0 {_41 = reader.readInt32() }
var _42: Api.StickerSet?
if Int(_2!) & Int(1 << 8) != 0 {_41 = reader.readInt32() }
var _42: Int32?
if Int(_2!) & Int(1 << 9) != 0 {_42 = reader.readInt32() }
var _43: Api.StickerSet?
if Int(_2!) & Int(1 << 10) != 0 {if let signature = reader.readInt32() {
_42 = Api.parse(reader, signature: signature) as? Api.StickerSet
_43 = Api.parse(reader, signature: signature) as? Api.StickerSet
} }
let _c1 = _1 != nil
let _c2 = _2 != nil
@@ -1178,13 +1182,14 @@ public extension Api {
let _c35 = (Int(_1!) & Int(1 << 28) == 0) || _35 != nil
let _c36 = (Int(_1!) & Int(1 << 29) == 0) || _36 != nil
let _c37 = (Int(_1!) & Int(1 << 30) == 0) || _37 != nil
let _c38 = (Int(_2!) & Int(1 << 4) == 0) || _38 != nil
let _c39 = (Int(_2!) & Int(1 << 7) == 0) || _39 != nil
let _c40 = (Int(_2!) & Int(1 << 8) == 0) || _40 != nil
let _c41 = (Int(_2!) & Int(1 << 9) == 0) || _41 != nil
let _c42 = (Int(_2!) & Int(1 << 10) == 0) || _42 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 && _c18 && _c19 && _c20 && _c21 && _c22 && _c23 && _c24 && _c25 && _c26 && _c27 && _c28 && _c29 && _c30 && _c31 && _c32 && _c33 && _c34 && _c35 && _c36 && _c37 && _c38 && _c39 && _c40 && _c41 && _c42 {
return Api.ChatFull.channelFull(flags: _1!, flags2: _2!, id: _3!, about: _4!, participantsCount: _5, adminsCount: _6, kickedCount: _7, bannedCount: _8, onlineCount: _9, readInboxMaxId: _10!, readOutboxMaxId: _11!, unreadCount: _12!, chatPhoto: _13!, notifySettings: _14!, exportedInvite: _15, botInfo: _16!, migratedFromChatId: _17, migratedFromMaxId: _18, pinnedMsgId: _19, stickerset: _20, availableMinId: _21, folderId: _22, linkedChatId: _23, location: _24, slowmodeSeconds: _25, slowmodeNextSendDate: _26, statsDc: _27, pts: _28!, call: _29, ttlPeriod: _30, pendingSuggestions: _31, groupcallDefaultJoinAs: _32, themeEmoticon: _33, requestsPending: _34, recentRequesters: _35, defaultSendAs: _36, availableReactions: _37, stories: _38, wallpaper: _39, boostsApplied: _40, boostsUnrestrict: _41, emojiset: _42)
let _c38 = (Int(_2!) & Int(1 << 13) == 0) || _38 != nil
let _c39 = (Int(_2!) & Int(1 << 4) == 0) || _39 != nil
let _c40 = (Int(_2!) & Int(1 << 7) == 0) || _40 != nil
let _c41 = (Int(_2!) & Int(1 << 8) == 0) || _41 != nil
let _c42 = (Int(_2!) & Int(1 << 9) == 0) || _42 != nil
let _c43 = (Int(_2!) & Int(1 << 10) == 0) || _43 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 && _c18 && _c19 && _c20 && _c21 && _c22 && _c23 && _c24 && _c25 && _c26 && _c27 && _c28 && _c29 && _c30 && _c31 && _c32 && _c33 && _c34 && _c35 && _c36 && _c37 && _c38 && _c39 && _c40 && _c41 && _c42 && _c43 {
return Api.ChatFull.channelFull(flags: _1!, flags2: _2!, id: _3!, about: _4!, participantsCount: _5, adminsCount: _6, kickedCount: _7, bannedCount: _8, onlineCount: _9, readInboxMaxId: _10!, readOutboxMaxId: _11!, unreadCount: _12!, chatPhoto: _13!, notifySettings: _14!, exportedInvite: _15, botInfo: _16!, migratedFromChatId: _17, migratedFromMaxId: _18, pinnedMsgId: _19, stickerset: _20, availableMinId: _21, folderId: _22, linkedChatId: _23, location: _24, slowmodeSeconds: _25, slowmodeNextSendDate: _26, statsDc: _27, pts: _28!, call: _29, ttlPeriod: _30, pendingSuggestions: _31, groupcallDefaultJoinAs: _32, themeEmoticon: _33, requestsPending: _34, recentRequesters: _35, defaultSendAs: _36, availableReactions: _37, reactionsLimit: _38, stories: _39, wallpaper: _40, boostsApplied: _41, boostsUnrestrict: _42, emojiset: _43)
}
else {
return nil
@@ -1243,6 +1248,8 @@ public extension Api {
if Int(_1!) & Int(1 << 18) != 0 {if let signature = reader.readInt32() {
_17 = Api.parse(reader, signature: signature) as? Api.ChatReactions
} }
var _18: Int32?
if Int(_1!) & Int(1 << 20) != 0 {_18 = reader.readInt32() }
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
@@ -1260,8 +1267,9 @@ public extension Api {
let _c15 = (Int(_1!) & Int(1 << 17) == 0) || _15 != nil
let _c16 = (Int(_1!) & Int(1 << 17) == 0) || _16 != nil
let _c17 = (Int(_1!) & Int(1 << 18) == 0) || _17 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 {
return Api.ChatFull.chatFull(flags: _1!, id: _2!, about: _3!, participants: _4!, chatPhoto: _5, notifySettings: _6!, exportedInvite: _7, botInfo: _8, pinnedMsgId: _9, folderId: _10, call: _11, ttlPeriod: _12, groupcallDefaultJoinAs: _13, themeEmoticon: _14, requestsPending: _15, recentRequesters: _16, availableReactions: _17)
let _c18 = (Int(_1!) & Int(1 << 20) == 0) || _18 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 && _c16 && _c17 && _c18 {
return Api.ChatFull.chatFull(flags: _1!, id: _2!, about: _3!, participants: _4!, chatPhoto: _5, notifySettings: _6!, exportedInvite: _7, botInfo: _8, pinnedMsgId: _9, folderId: _10, call: _11, ttlPeriod: _12, groupcallDefaultJoinAs: _13, themeEmoticon: _14, requestsPending: _15, recentRequesters: _16, availableReactions: _17, reactionsLimit: _18)
}
else {
return nil
@@ -6,7 +6,7 @@ import TelegramCore
import TelegramPresentationData
import AccountContext
public final class MediaNavigationAccessoryContainerNode: ASDisplayNode, UIGestureRecognizerDelegate {
public final class MediaNavigationAccessoryContainerNode: ASDisplayNode, ASGestureRecognizerDelegate {
private let displayBackground: Bool
public let backgroundNode: ASDisplayNode
@@ -140,7 +140,7 @@ private func generateMaskImage(color: UIColor) -> UIImage? {
})
}
public final class MediaNavigationAccessoryHeaderNode: ASDisplayNode, UIScrollViewDelegate {
public final class MediaNavigationAccessoryHeaderNode: ASDisplayNode, ASScrollViewDelegate {
public static let minimizedHeight: CGFloat = 37.0
private let context: AccountContext
@@ -345,7 +345,7 @@ public final class MediaNavigationAccessoryHeaderNode: ASDisplayNode, UIScrollVi
self.view.disablesInteractiveTransitionGestureRecognizer = true
self.scrollNode.view.alwaysBounceHorizontal = true
self.scrollNode.view.delegate = self
self.scrollNode.view.delegate = self.wrappedScrollViewDelegate
self.scrollNode.view.isPagingEnabled = true
self.scrollNode.view.showsHorizontalScrollIndicator = false
self.scrollNode.view.showsVerticalScrollIndicator = false
@@ -112,7 +112,7 @@ final class VoiceChatCameraPreviewController: ViewController {
}
}
private class VoiceChatCameraPreviewControllerNode: ViewControllerTracingNode, UIScrollViewDelegate {
private class VoiceChatCameraPreviewControllerNode: ViewControllerTracingNode, ASScrollViewDelegate {
private weak var controller: VoiceChatCameraPreviewController?
private let sharedContext: SharedAccountContext
private var presentationData: PresentationData
@@ -223,7 +223,7 @@ private class VoiceChatCameraPreviewControllerNode: ViewControllerTracingNode, U
self.dimNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimTapGesture(_:))))
self.addSubnode(self.dimNode)
self.wrappingScrollNode.view.delegate = self
self.wrappingScrollNode.view.delegate = self.wrappedScrollViewDelegate
self.addSubnode(self.wrappingScrollNode)
self.wrappingScrollNode.addSubnode(self.backgroundNode)
@@ -510,7 +510,7 @@ private class VoiceChatCameraPreviewControllerNode: ViewControllerTracingNode, U
private let textFont = Font.with(size: 14.0, design: .camera, weight: .regular)
private let selectedTextFont = Font.with(size: 14.0, design: .camera, weight: .semibold)
private class WheelControlNode: ASDisplayNode, UIGestureRecognizerDelegate {
private class WheelControlNode: ASDisplayNode, ASGestureRecognizerDelegate {
struct Item: Equatable {
public let title: String
@@ -254,7 +254,7 @@ public final class VoiceChatControllerImpl: ViewController, VoiceChatController
case fullscreen(controlsHidden: Bool)
}
fileprivate final class Node: ViewControllerTracingNode, UIGestureRecognizerDelegate {
fileprivate final class Node: ViewControllerTracingNode, ASGestureRecognizerDelegate {
private struct ListTransition {
let deletions: [ListViewDeleteItem]
let insertions: [ListViewInsertItem]
@@ -3022,11 +3022,11 @@ public final class VoiceChatControllerImpl: ViewController, VoiceChatController
let longTapRecognizer = UILongPressGestureRecognizer(target: self, action: #selector(self.actionButtonPressGesture(_:)))
longTapRecognizer.minimumPressDuration = 0.001
longTapRecognizer.delegate = self
longTapRecognizer.delegate = self.wrappedGestureRecognizerDelegate
self.actionButton.view.addGestureRecognizer(longTapRecognizer)
let panRecognizer = DirectionalPanGestureRecognizer(target: self, action: #selector(self.panGesture(_:)))
panRecognizer.delegate = self
panRecognizer.delegate = self.wrappedGestureRecognizerDelegate
panRecognizer.delaysTouchesBegan = false
panRecognizer.cancelsTouchesInView = true
self.view.addGestureRecognizer(panRecognizer)
@@ -6747,7 +6747,7 @@ public final class VoiceChatControllerImpl: ViewController, VoiceChatController
self.updateDecorationsLayout(transition: transition)
}
}
if false, let (peerId, _) = minimalVisiblePeerid {
if !"".isEmpty, let (peerId, _) = minimalVisiblePeerid {
var index = 0
for item in self.currentEntries {
if case let .peer(entry, _) = item, entry.peer.id == peerId {
@@ -176,7 +176,7 @@ public final class VoiceChatJoinScreen: ViewController {
self.controllerNode.containerLayoutUpdated(layout, navigationBarHeight: self.navigationLayout(layout: layout).navigationFrame.maxY, transition: transition)
}
class Node: ViewControllerTracingNode, UIScrollViewDelegate {
class Node: ViewControllerTracingNode, ASScrollViewDelegate {
private let context: AccountContext
private var presentationData: PresentationData
private let asSpeaker: Bool
@@ -285,7 +285,7 @@ public final class VoiceChatJoinScreen: ViewController {
self.dimNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimTapGesture(_:))))
self.addSubnode(self.dimNode)
self.wrappingScrollNode.view.delegate = self
self.wrappingScrollNode.view.delegate = self.wrappedScrollViewDelegate
self.addSubnode(self.wrappingScrollNode)
self.cancelButtonNode.setTitle(self.presentationData.strings.Common_Cancel, with: Font.medium(20.0), with: self.presentationData.theme.actionSheet.standardActionTextColor, for: .normal)
@@ -17,7 +17,7 @@ import TooltipUI
private let slideOffset: CGFloat = 80.0 + 44.0
public final class VoiceChatOverlayController: ViewController {
private final class Node: ViewControllerTracingNode, UIGestureRecognizerDelegate {
private final class Node: ViewControllerTracingNode, ASGestureRecognizerDelegate {
private weak var controller: VoiceChatOverlayController?
private var validLayout: ContainerViewLayout?
@@ -90,7 +90,7 @@ final class VoiceChatRecordingSetupController: ViewController {
}
}
private class VoiceChatRecordingSetupControllerNode: ViewControllerTracingNode, UIScrollViewDelegate {
private class VoiceChatRecordingSetupControllerNode: ViewControllerTracingNode, ASScrollViewDelegate {
enum MediaMode {
case videoAndAudio
case audioOnly
@@ -263,7 +263,7 @@ private class VoiceChatRecordingSetupControllerNode: ViewControllerTracingNode,
self.dimNode.view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(self.dimTapGesture(_:))))
self.addSubnode(self.dimNode)
self.wrappingScrollNode.view.delegate = self
self.wrappingScrollNode.view.delegate = self.wrappedScrollViewDelegate
self.addSubnode(self.wrappingScrollNode)
self.wrappingScrollNode.addSubnode(self.backgroundNode)
@@ -1278,6 +1278,7 @@ public class Account {
self.stateManager.updateConfigRequested = { [weak self] in
self?.restartConfigurationUpdates()
self?.taskManager?.reloadAppConfiguration()
}
self.restartConfigurationUpdates()
@@ -7,27 +7,18 @@ public final class AdMessageAttribute: MessageAttribute {
case recommended
}
public enum MessageTarget {
case peer(id: EnginePeer.Id, message: EngineMessage.Id?, startParam: String?)
case join(title: String, joinHash: String, peer: EnginePeer?)
case webPage(title: String, url: String)
case botApp(peerId: EnginePeer.Id, app: BotApp, startParam: String?)
}
public let opaqueId: Data
public let messageType: MessageType
public let displayAvatar: Bool
public let target: MessageTarget
public let buttonText: String?
public let url: String
public let buttonText: String
public let sponsorInfo: String?
public let additionalInfo: String?
public let canReport: Bool
public init(opaqueId: Data, messageType: MessageType, displayAvatar: Bool, target: MessageTarget, buttonText: String?, sponsorInfo: String?, additionalInfo: String?, canReport: Bool) {
public init(opaqueId: Data, messageType: MessageType, url: String, buttonText: String, sponsorInfo: String?, additionalInfo: String?, canReport: Bool) {
self.opaqueId = opaqueId
self.messageType = messageType
self.displayAvatar = displayAvatar
self.target = target
self.url = url
self.buttonText = buttonText
self.sponsorInfo = sponsorInfo
self.additionalInfo = additionalInfo
@@ -18,6 +18,7 @@ final class AccountTaskManager {
private var stateDisposable: Disposable?
private let tasksDisposable = MetaDisposable()
private let configurationDisposable = MetaDisposable()
private let managedTopReactionsDisposable = MetaDisposable()
@@ -118,7 +119,7 @@ final class AccountTaskManager {
self.managedTopReactionsDisposable.set(managedTopReactions(postbox: self.stateManager.postbox, network: self.stateManager.network).start())
//tasks.add(managedVoipConfigurationUpdates(postbox: self.stateManager.postbox, network: self.stateManager.network).start())
tasks.add(managedAppConfigurationUpdates(postbox: self.stateManager.postbox, network: self.stateManager.network).start())
self.reloadAppConfiguration()
tasks.add(managedPremiumPromoConfigurationUpdates(accountPeerId: self.accountPeerId, postbox: self.stateManager.postbox, network: self.stateManager.network).start())
tasks.add(managedAutodownloadSettingsUpdates(accountManager: self.accountManager, network: self.stateManager.network).start())
tasks.add(managedTermsOfServiceUpdates(postbox: self.stateManager.postbox, network: self.stateManager.network, stateManager: self.stateManager).start())
@@ -143,8 +144,13 @@ final class AccountTaskManager {
deinit {
self.stateDisposable?.dispose()
self.tasksDisposable.dispose()
self.configurationDisposable.dispose()
self.managedTopReactionsDisposable.dispose()
}
func reloadAppConfiguration() {
self.configurationDisposable.set(managedAppConfigurationUpdates(postbox: self.stateManager.postbox, network: self.stateManager.network).start())
}
}
private let queue: Queue
@@ -158,4 +164,10 @@ final class AccountTaskManager {
return Impl(queue: queue, accountPeerId: stateManager.accountPeerId, stateManager: stateManager, accountManager: accountManager, networkArguments: networkArguments, viewTracker: viewTracker, mediaReferenceRevalidationContext: mediaReferenceRevalidationContext, isMainApp: isMainApp, testingEnvironment: testingEnvironment)
})
}
func reloadAppConfiguration() {
self.impl.with { impl in
impl.reloadAppConfiguration()
}
}
}
@@ -674,7 +674,7 @@ func _internal_updatePeerAllowedReactions(account: Account, peerId: PeerId, allo
mappedReactions = .chatReactionsNone
}
return account.network.request(Api.functions.messages.setChatAvailableReactions(peer: inputPeer, availableReactions: mappedReactions))
return account.network.request(Api.functions.messages.setChatAvailableReactions(flags: 0, peer: inputPeer, availableReactions: mappedReactions, reactionsLimit: nil))
|> map(Optional.init)
|> `catch` { error -> Signal<Api.Updates?, UpdatePeerAllowedReactionsError> in
if error.errorDescription == "CHAT_NOT_MODIFIED" {
@@ -210,7 +210,7 @@ public class BoxedMessage: NSObject {
public class Serialization: NSObject, MTSerialization {
public func currentLayer() -> UInt {
return 177
return 178
}
public func parseMessage(_ data: Data!) -> Any! {
@@ -14,6 +14,7 @@ public enum ServerProvidedSuggestion: String {
case restorePremium = "PREMIUM_RESTORE"
case xmasPremiumGift = "PREMIUM_CHRISTMAS"
case setupBirthday = "BIRTHDAY_SETUP"
case todayBirthdays = "BIRTHDAY_CONTACTS_TODAY"
}
private var dismissedSuggestionsPromise = ValuePromise<[AccountRecordId: Set<ServerProvidedSuggestion>]>([:])
@@ -45,6 +46,30 @@ func _internal_getServerProvidedSuggestions(account: Account) -> Signal<[ServerP
|> distinctUntilChanged
}
func _internal_getServerDismissedSuggestions(account: Account) -> Signal<[ServerProvidedSuggestion], NoError> {
let key: PostboxViewKey = .preferences(keys: Set([PreferencesKeys.appConfiguration]))
return combineLatest(account.postbox.combinedView(keys: [key]), dismissedSuggestionsPromise.get())
|> map { views, dismissedSuggestionsValue -> [ServerProvidedSuggestion] in
let dismissedSuggestions = dismissedSuggestionsValue[account.id] ?? Set()
guard let view = views.views[key] as? PreferencesView else {
return []
}
guard let appConfiguration = view.values[PreferencesKeys.appConfiguration]?.get(AppConfiguration.self) else {
return []
}
guard let data = appConfiguration.data, let listItems = data["hidden_suggestions"] as? [String] else {
return []
}
var items = listItems.compactMap { item -> ServerProvidedSuggestion? in
return ServerProvidedSuggestion(rawValue: item)
}
items.append(contentsOf: dismissedSuggestions)
return items
}
|> distinctUntilChanged
}
func _internal_dismissServerProvidedSuggestion(account: Account, suggestion: ServerProvidedSuggestion) -> Signal<Never, NoError> {
if let _ = dismissedSuggestions[account.id] {
dismissedSuggestions[account.id]?.insert(suggestion)
@@ -297,6 +297,7 @@ public struct CachedUserFlags: OptionSet {
public static let isBlockedFromStories = CachedUserFlags(rawValue: 1 << 1)
public static let readDatesPrivate = CachedUserFlags(rawValue: 1 << 2)
public static let premiumRequired = CachedUserFlags(rawValue: 1 << 3)
public static let adsEnabled = CachedUserFlags(rawValue: 1 << 4)
}
public final class EditableBotInfo: PostboxCoding, Equatable {
@@ -233,5 +233,9 @@ public extension TelegramEngine {
public func updatePersonalChannel(personalChannel: TelegramPersonalChannel?) -> Signal<Never, NoError> {
return _internal_updatePersonalChannel(account: self.account, personalChannel: personalChannel)
}
public func updateAdMessagesEnabled(enabled: Bool) -> Signal<Never, AdMessagesEnableError> {
return _internal_updateAdMessagesEnabled(account: self.account, enabled: enabled)
}
}
}
@@ -1896,5 +1896,33 @@ public extension TelegramEngine.EngineData.Item {
}
}
}
public struct AdsEnabled: TelegramEngineDataItem, TelegramEngineMapKeyDataItem, PostboxViewDataItem {
public typealias Result = Bool
fileprivate var id: EnginePeer.Id
public var mapKey: EnginePeer.Id {
return self.id
}
public init(id: EnginePeer.Id) {
self.id = id
}
var key: PostboxViewKey {
return .cachedPeerData(peerId: self.id)
}
func extract(view: PostboxView) -> Result {
guard let view = view as? CachedPeerDataView else {
preconditionFailure()
}
if let cachedData = view.cachedPeerData as? CachedUserData {
return cachedData.flags.contains(.adsEnabled)
} else {
return false
}
}
}
}
}
@@ -8,13 +8,11 @@ private class AdMessagesHistoryContextImpl {
enum CodingKeys: String, CodingKey {
case opaqueId
case messageType
case displayAvatar
case title
case text
case textEntities
case media
case target
case messageId
case startParam
case url
case buttonText
case sponsorInfo
case additionalInfo
@@ -26,147 +24,14 @@ private class AdMessagesHistoryContextImpl {
case recommended = 1
}
enum Target: Equatable, Codable {
enum DecodingError: Error {
case generic
}
enum CodingKeys: String, CodingKey {
case peer
case invite
case webPage
case botApp
}
struct Invite: Equatable, Codable {
enum CodingKeys: String, CodingKey {
case title
case joinHash
case nameColor
case image
case peer
}
var title: String
var joinHash: String
var nameColor: PeerNameColor?
var image: TelegramMediaImage?
var peer: Peer?
init(title: String, joinHash: String, nameColor: PeerNameColor?, image: TelegramMediaImage?, peer: Peer?) {
self.title = title
self.joinHash = joinHash
self.nameColor = nameColor
self.image = image
self.peer = peer
}
static func ==(lhs: Invite, rhs: Invite) -> Bool {
if lhs.title != rhs.title {
return false
}
if lhs.joinHash != rhs.joinHash {
return false
}
if lhs.nameColor != rhs.nameColor {
return false
}
if lhs.image != rhs.image {
return false
}
if !arePeersEqual(lhs.peer, rhs.peer) {
return false
}
return true
}
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
self.title = try container.decode(String.self, forKey: .title)
self.joinHash = try container.decode(String.self, forKey: .joinHash)
self.nameColor = try container.decodeIfPresent(Int32.self, forKey: .nameColor).flatMap { PeerNameColor(rawValue: $0) }
self.image = (try container.decodeIfPresent(Data.self, forKey: .image)).flatMap { data in
return TelegramMediaImage(decoder: PostboxDecoder(buffer: MemoryBuffer(data: data)))
}
self.peer = (try container.decodeIfPresent(Data.self, forKey: .peer)).flatMap { data in
return PostboxDecoder(buffer: MemoryBuffer(data: data)).decodeRootObject() as? Peer
}
}
func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(self.title, forKey: .title)
try container.encode(self.joinHash, forKey: .joinHash)
try container.encodeIfPresent(self.nameColor?.rawValue, forKey: .nameColor)
try container.encodeIfPresent(self.image.flatMap { image in
let encoder = PostboxEncoder()
image.encode(encoder)
return encoder.makeData()
}, forKey: .image)
try container.encodeIfPresent(self.peer.flatMap { peer in
let encoder = PostboxEncoder()
encoder.encodeRootObject(peer)
return encoder.makeData()
}, forKey: .peer)
}
}
struct WebPage: Equatable, Codable {
var title: String
var url: String
var photo: TelegramMediaImage?
}
case peer(PeerId)
case invite(Invite)
case webPage(WebPage)
case botApp(PeerId, BotApp)
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
if let botApp = try container.decodeIfPresent(BotApp.self, forKey: .botApp), let peer = try container.decodeIfPresent(Int64.self, forKey: .peer) {
self = .botApp(PeerId(peer), botApp)
} else if let peer = try container.decodeIfPresent(Int64.self, forKey: .peer) {
self = .peer(PeerId(peer))
} else if let invite = try container.decodeIfPresent(Invite.self, forKey: .invite) {
self = .invite(invite)
} else if let webPage = try container.decodeIfPresent(WebPage.self, forKey: .webPage) {
self = .webPage(webPage)
} else {
throw DecodingError.generic
}
}
func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
switch self {
case let .peer(peerId):
try container.encode(peerId.toInt64(), forKey: .peer)
case let .invite(invite):
try container.encode(invite, forKey: .invite)
case let .webPage(webPage):
try container.encode(webPage, forKey: .webPage)
case let .botApp(peerId, botApp):
try container.encode(peerId.toInt64(), forKey: .peer)
try container.encode(botApp, forKey: .botApp)
}
}
}
public let opaqueId: Data
public let messageType: MessageType
public let displayAvatar: Bool
public let title: String
public let text: String
public let textEntities: [MessageTextEntity]
public let media: [Media]
public let target: Target
public let messageId: MessageId?
public let startParam: String?
public let buttonText: String?
public let url: String
public let buttonText: String
public let sponsorInfo: String?
public let additionalInfo: String?
public let canReport: Bool
@@ -174,27 +39,23 @@ private class AdMessagesHistoryContextImpl {
public init(
opaqueId: Data,
messageType: MessageType,
displayAvatar: Bool,
title: String,
text: String,
textEntities: [MessageTextEntity],
media: [Media],
target: Target,
messageId: MessageId?,
startParam: String?,
buttonText: String?,
url: String,
buttonText: String,
sponsorInfo: String?,
additionalInfo: String?,
canReport: Bool
) {
self.opaqueId = opaqueId
self.messageType = messageType
self.displayAvatar = displayAvatar
self.title = title
self.text = text
self.textEntities = textEntities
self.media = media
self.target = target
self.messageId = messageId
self.startParam = startParam
self.url = url
self.buttonText = buttonText
self.sponsorInfo = sponsorInfo
self.additionalInfo = additionalInfo
@@ -212,8 +73,7 @@ private class AdMessagesHistoryContextImpl {
self.messageType = .sponsored
}
self.displayAvatar = try container.decodeIfPresent(Bool.self, forKey: .displayAvatar) ?? false
self.title = try container.decode(String.self, forKey: .title)
self.text = try container.decode(String.self, forKey: .text)
self.textEntities = try container.decode([MessageTextEntity].self, forKey: .textEntities)
@@ -222,15 +82,13 @@ private class AdMessagesHistoryContextImpl {
return PostboxDecoder(buffer: MemoryBuffer(data: data)).decodeRootObject() as? Media
}
self.target = try container.decode(Target.self, forKey: .target)
self.messageId = try container.decodeIfPresent(MessageId.self, forKey: .messageId)
self.startParam = try container.decodeIfPresent(String.self, forKey: .startParam)
self.buttonText = try container.decodeIfPresent(String.self, forKey: .buttonText)
self.url = try container.decode(String.self, forKey: .url)
self.buttonText = try container.decode(String.self, forKey: .buttonText)
self.sponsorInfo = try container.decodeIfPresent(String.self, forKey: .sponsorInfo)
self.additionalInfo = try container.decodeIfPresent(String.self, forKey: .additionalInfo)
self.canReport = try container.decodeIfPresent(Bool.self, forKey: .displayAvatar) ?? false
self.canReport = try container.decodeIfPresent(Bool.self, forKey: .canReport) ?? false
}
public func encode(to encoder: Encoder) throws {
@@ -238,7 +96,7 @@ private class AdMessagesHistoryContextImpl {
try container.encode(self.opaqueId, forKey: .opaqueId)
try container.encode(self.messageType.rawValue, forKey: .messageType)
try container.encode(self.displayAvatar, forKey: .displayAvatar)
try container.encode(self.title, forKey: .title)
try container.encode(self.text, forKey: .text)
try container.encode(self.textEntities, forKey: .textEntities)
@@ -249,10 +107,8 @@ private class AdMessagesHistoryContextImpl {
}
try container.encode(mediaData, forKey: .media)
try container.encode(self.target, forKey: .target)
try container.encodeIfPresent(self.messageId, forKey: .messageId)
try container.encodeIfPresent(self.startParam, forKey: .startParam)
try container.encodeIfPresent(self.buttonText, forKey: .buttonText)
try container.encode(self.url, forKey: .url)
try container.encode(self.buttonText, forKey: .buttonText)
try container.encodeIfPresent(self.sponsorInfo, forKey: .sponsorInfo)
try container.encodeIfPresent(self.additionalInfo, forKey: .additionalInfo)
@@ -267,6 +123,9 @@ private class AdMessagesHistoryContextImpl {
if lhs.messageType != rhs.messageType {
return false
}
if lhs.title != rhs.title {
return false
}
if lhs.text != rhs.text {
return false
}
@@ -281,13 +140,7 @@ private class AdMessagesHistoryContextImpl {
return false
}
}
if lhs.target != rhs.target {
return false
}
if lhs.messageId != rhs.messageId {
return false
}
if lhs.startParam != rhs.startParam {
if lhs.url != rhs.url {
return false
}
if lhs.buttonText != rhs.buttonText {
@@ -308,17 +161,6 @@ private class AdMessagesHistoryContextImpl {
func toMessage(peerId: PeerId, transaction: Transaction) -> Message? {
var attributes: [MessageAttribute] = []
let target: AdMessageAttribute.MessageTarget
switch self.target {
case let .peer(peerId):
target = .peer(id: peerId, message: self.messageId, startParam: self.startParam)
case let .invite(invite):
target = .join(title: invite.title, joinHash: invite.joinHash, peer: invite.peer.flatMap(EnginePeer.init))
case let .webPage(webPage):
target = .webPage(title: webPage.title, url: webPage.url)
case let .botApp(peerId, botApp):
target = .botApp(peerId: peerId, app: botApp, startParam: self.startParam)
}
let mappedMessageType: AdMessageAttribute.MessageType
switch self.messageType {
case .sponsored:
@@ -326,7 +168,7 @@ private class AdMessagesHistoryContextImpl {
case .recommended:
mappedMessageType = .recommended
}
attributes.append(AdMessageAttribute(opaqueId: self.opaqueId, messageType: mappedMessageType, displayAvatar: self.displayAvatar && !self.canReport, target: target, buttonText: self.buttonText, sponsorInfo: self.sponsorInfo, additionalInfo: self.additionalInfo, canReport: self.canReport))
attributes.append(AdMessageAttribute(opaqueId: self.opaqueId, messageType: mappedMessageType, url: self.url, buttonText: self.buttonText, sponsorInfo: self.sponsorInfo, additionalInfo: self.additionalInfo, canReport: self.canReport))
if !self.textEntities.isEmpty {
let attribute = TextEntitiesMessageAttribute(entities: self.textEntities)
attributes.append(attribute)
@@ -338,81 +180,35 @@ private class AdMessagesHistoryContextImpl {
messagePeers[peer.id] = peer
}
let author: Peer
switch self.target {
case let .peer(peerId), let .botApp(peerId, _):
if let peer = transaction.getPeer(peerId) {
author = peer
} else {
return nil
}
case let .invite(invite):
author = TelegramChannel(
id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(1)),
accessHash: nil,
title: invite.title,
username: nil,
photo: [],
creationDate: 0,
version: 0,
participationStatus: .left,
info: .broadcast(TelegramChannelBroadcastInfo(flags: [])),
flags: [],
restrictionInfo: nil,
adminRights: nil,
bannedRights: nil,
defaultBannedRights: nil,
usernames: [],
storiesHidden: nil,
nameColor: invite.nameColor,
backgroundEmojiId: nil,
profileColor: nil,
profileBackgroundEmojiId: nil,
emojiStatus: nil,
approximateBoostLevel: nil
)
case let .webPage(webPage):
author = TelegramChannel(
id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(1)),
accessHash: nil,
title: webPage.title,
username: nil,
photo: webPage.photo?.representations ?? [],
creationDate: 0,
version: 0,
participationStatus: .left,
info: .broadcast(TelegramChannelBroadcastInfo(flags: [])),
flags: [],
restrictionInfo: nil,
adminRights: nil,
bannedRights: nil,
defaultBannedRights: nil,
usernames: [],
storiesHidden: nil,
nameColor: .blue,
backgroundEmojiId: nil,
profileColor: nil,
profileBackgroundEmojiId: nil,
emojiStatus: nil,
approximateBoostLevel: nil
)
}
let author: Peer = TelegramChannel(
id: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(1)),
accessHash: nil,
title: self.title,
username: nil,
photo: [],
creationDate: 0,
version: 0,
participationStatus: .left,
info: .broadcast(TelegramChannelBroadcastInfo(flags: [])),
flags: [],
restrictionInfo: nil,
adminRights: nil,
bannedRights: nil,
defaultBannedRights: nil,
usernames: [],
storiesHidden: nil,
nameColor: .blue,
backgroundEmojiId: nil,
profileColor: nil,
profileBackgroundEmojiId: nil,
emojiStatus: nil,
approximateBoostLevel: nil
)
messagePeers[author.id] = author
let messageHash = (self.text.hashValue &+ 31 &* peerId.hashValue) &* 31 &+ author.id.hashValue
let messageStableVersion = UInt32(bitPattern: Int32(truncatingIfNeeded: messageHash))
var media: [Media] = self.media
if media.isEmpty {
if case let .invite(invite) = self.target, let image = invite.image {
media.append(image)
} else if self.displayAvatar && self.canReport, let profileImage = author.smallProfileImage {
media.append(TelegramMediaImage(imageId: MediaId(namespace: 0, id: 0), representations: [profileImage], immediateThumbnailData: nil, reference: nil, partialReference: nil, flags: []))
}
}
return Message(
stableId: 0,
stableVersion: messageStableVersion,
@@ -431,7 +227,7 @@ private class AdMessagesHistoryContextImpl {
author: author,
text: self.text,
attributes: attributes,
media: media,
media: self.media,
peers: messagePeers,
associatedMessages: SimpleDictionary<MessageId, Message>(),
associatedMessageIds: [],
@@ -612,100 +408,30 @@ private class AdMessagesHistoryContextImpl {
for message in messages {
switch message {
case let .sponsoredMessage(flags, randomId, fromId, chatInvite, chatInviteHash, channelPost, startParam, webPage, botApp, message, entities, buttonText, sponsorInfo, additionalInfo):
case let .sponsoredMessage(flags, randomId, url, title, message, entities, photo, buttonText, sponsorInfo, additionalInfo):
var parsedEntities: [MessageTextEntity] = []
if let entities = entities {
parsedEntities = messageTextEntitiesFromApiEntities(entities)
}
let isRecommended = (flags & (1 << 5)) != 0
var displayAvatar = (flags & (1 << 6)) != 0
let canReport = (flags & (1 << 12)) != 0
var target: CachedMessage.Target?
if let fromId = fromId {
if let botApp = botApp, let app = BotApp(apiBotApp: botApp) {
target = .botApp(fromId.peerId, app)
} else {
target = .peer(fromId.peerId)
}
} else if let webPage = webPage {
switch webPage {
case let .sponsoredWebPage(_, url, siteName, photo):
let photo = photo.flatMap { telegramMediaImageFromApiPhoto($0) }
target = .webPage(CachedMessage.Target.WebPage(title: siteName, url: url, photo: photo))
}
} else if let chatInvite = chatInvite, let chatInviteHash = chatInviteHash {
switch chatInvite {
case let .chatInvite(flags, title, _, photo, participantsCount, participants, nameColor):
let image = telegramMediaImageFromApiPhoto(photo)
let flags: ExternalJoiningChatState.Invite.Flags = .init(isChannel: (flags & (1 << 0)) != 0, isBroadcast: (flags & (1 << 1)) != 0, isPublic: (flags & (1 << 2)) != 0, isMegagroup: (flags & (1 << 3)) != 0, requestNeeded: (flags & (1 << 6)) != 0, isVerified: (flags & (1 << 7)) != 0, isScam: (flags & (1 << 8)) != 0, isFake: (flags & (1 << 9)) != 0)
let _ = flags
let _ = participantsCount
let _ = participants
target = .invite(CachedMessage.Target.Invite(
title: title,
joinHash: chatInviteHash,
nameColor: PeerNameColor(rawValue: nameColor),
image: displayAvatar ? image : nil,
peer: nil
))
displayAvatar = false
case let .chatInvitePeek(chat, _):
if let peer = parseTelegramGroupOrChannel(chat: chat) {
target = .invite(CachedMessage.Target.Invite(
title: peer.debugDisplayTitle,
joinHash: chatInviteHash,
nameColor: peer.nameColor,
image: nil,
peer: displayAvatar ? peer : nil
))
}
displayAvatar = false
case let .chatInviteAlready(chat):
if let peer = parseTelegramGroupOrChannel(chat: chat) {
target = .invite(CachedMessage.Target.Invite(
title: peer.debugDisplayTitle,
joinHash: chatInviteHash,
nameColor: peer.nameColor,
image: nil,
peer: displayAvatar ? peer : nil
))
}
displayAvatar = false
}
}
// else if let botApp = app.flatMap({ BotApp(apiBotApp: $0) }) {
// target = .botApp(botApp)
// }
var messageId: MessageId?
if let fromId = fromId, let channelPost = channelPost {
messageId = MessageId(peerId: fromId.peerId, namespace: Namespaces.Message.Cloud, id: channelPost)
}
let photo = photo.flatMap { telegramMediaImageFromApiPhoto($0) }
if let target = target {
parsedMessages.append(CachedMessage(
opaqueId: randomId.makeData(),
messageType: isRecommended ? .recommended : .sponsored,
displayAvatar: displayAvatar,
text: message,
textEntities: parsedEntities,
media: [],
target: target,
messageId: messageId,
startParam: startParam,
buttonText: buttonText,
sponsorInfo: sponsorInfo,
additionalInfo: additionalInfo,
canReport: canReport
))
}
parsedMessages.append(CachedMessage(
opaqueId: randomId.makeData(),
messageType: isRecommended ? .recommended : .sponsored,
title: title,
text: message,
textEntities: parsedEntities,
media: photo.flatMap { [$0] } ?? [],
url: url,
buttonText: buttonText,
sponsorInfo: sponsorInfo,
additionalInfo: additionalInfo,
canReport: canReport
))
}
}
@@ -25,6 +25,10 @@ public extension TelegramEngine {
return _internal_getServerProvidedSuggestions(account: self.account)
}
public func getServerDismissedSuggestions() -> Signal<[ServerProvidedSuggestion], NoError> {
return _internal_getServerDismissedSuggestions(account: self.account)
}
public func dismissServerProvidedSuggestion(suggestion: ServerProvidedSuggestion) -> Signal<Never, NoError> {
return _internal_dismissServerProvidedSuggestion(account: self.account, suggestion: suggestion)
}
@@ -45,3 +45,36 @@ func _internal_updateChannelRestrictAdMessages(account: Account, peerId: PeerId,
}
}
public enum AdMessagesEnableError {
case generic
}
func _internal_updateAdMessagesEnabled(account: Account, enabled: Bool) -> Signal<Never, AdMessagesEnableError> {
return account.network.request(Api.functions.account.toggleSponsoredMessages(enabled: enabled ? .boolTrue : .boolFalse))
|> `catch` { error -> Signal<Api.Bool, AdMessagesEnableError> in
return .fail(.generic)
}
|> mapToSignal { result -> Signal<Never, AdMessagesEnableError> in
guard case .boolTrue = result else {
return .fail(.generic)
}
return account.postbox.transaction { transaction -> Void in
transaction.updatePeerCachedData(peerIds: [account.peerId], update: { peerId, currentData in
if let currentData = currentData as? CachedUserData {
var flags = currentData.flags
if enabled {
flags.insert(.adsEnabled)
} else {
flags.remove(.adsEnabled)
}
return currentData.withUpdatedFlags(flags)
} else {
return currentData
}
})
}
|> castError(AdMessagesEnableError.self)
|> ignoreValues
}
}

Some files were not shown because too many files have changed in this diff Show More