diff --git a/submodules/BrowserUI/Sources/BrowserScreen.swift b/submodules/BrowserUI/Sources/BrowserScreen.swift index 2d8f5e864e..aeb2e445d6 100644 --- a/submodules/BrowserUI/Sources/BrowserScreen.swift +++ b/submodules/BrowserUI/Sources/BrowserScreen.swift @@ -623,7 +623,7 @@ public class BrowserScreen: ViewController, MinimizableController { self.controller?.present(UndoOverlayController(presentationData: presentationData, content: .forward(savedMessages: savedMessages, text: text), elevatedLayout: false, animateInAsReplacement: true, action: { [weak self] action in if savedMessages, let self, action == .info { let _ = (self.context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: self.context.account.peerId)) - |> deliverOnMainQueue).start(next: { [weak self] peer in + |> deliverOnMainQueue).start(next: { [weak self] peer in guard let self, let peer else { return } diff --git a/submodules/SemanticStatusNode/Sources/SemanticStatusNode.swift b/submodules/SemanticStatusNode/Sources/SemanticStatusNode.swift index d6864b7632..85e18dd8fc 100644 --- a/submodules/SemanticStatusNode/Sources/SemanticStatusNode.swift +++ b/submodules/SemanticStatusNode/Sources/SemanticStatusNode.swift @@ -400,8 +400,6 @@ public final class SemanticStatusNode: ASControlNode { super.init() - self.layer.addSublayer(self.hierarchyTrackingLayer) - self.isOpaque = false self.displaysAsynchronously = false @@ -410,6 +408,12 @@ public final class SemanticStatusNode: ASControlNode { } } + public override func didLoad() { + super.didLoad() + + self.layer.addSublayer(self.hierarchyTrackingLayer) + } + deinit { self.disposable?.dispose() } diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift b/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift index b511fefa55..05c3d070b3 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift @@ -974,8 +974,8 @@ private final class ProfileGiftsContextImpl { private let cacheDisposable = MetaDisposable() private let actionDisposable = MetaDisposable() - private var sorting: ProfileGiftsContext.Sorting = .date - private var filter: ProfileGiftsContext.Filters = ProfileGiftsContext.Filters.All + private var sorting: ProfileGiftsContext.Sorting + private var filter: ProfileGiftsContext.Filters private var gifts: [ProfileGiftsContext.State.StarGift] = [] private var count: Int32? @@ -993,10 +993,18 @@ private final class ProfileGiftsContextImpl { return self.stateValue.get() } - init(queue: Queue, account: Account, peerId: EnginePeer.Id) { + init( + queue: Queue, + account: Account, + peerId: EnginePeer.Id, + sorting: ProfileGiftsContext.Sorting, + filter: ProfileGiftsContext.Filters + ) { self.queue = queue self.account = account self.peerId = peerId + self.sorting = sorting + self.filter = filter self.loadMore() } @@ -1664,10 +1672,15 @@ public final class ProfileGiftsContext { } } - public init(account: Account, peerId: EnginePeer.Id) { + public init( + account: Account, + peerId: EnginePeer.Id, + sorting: ProfileGiftsContext.Sorting = .date, + filter: ProfileGiftsContext.Filters = .All + ) { let queue = self.queue self.impl = QueueLocalObject(queue: queue, generate: { - return ProfileGiftsContextImpl(queue: queue, account: account, peerId: peerId) + return ProfileGiftsContextImpl(queue: queue, account: account, peerId: peerId, sorting: sorting, filter: filter) }) } diff --git a/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift index 3941d0ea01..0d2fea8a25 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift @@ -142,16 +142,12 @@ final class GiftOptionsScreenComponent: Component { private var _effectiveStarGifts: ([StarGift], StarsFilter)? private var effectiveStarGifts: [StarGift]? { get { - if let (currentGifts, currentFilter) = self._effectiveStarGifts, currentFilter == self.starsFilter { + if let (currentGifts, currentFilter) = self._effectiveStarGifts, currentFilter == self.starsFilter && currentFilter != .transfer { return currentGifts } else if let allGifts = self.state?.starGifts { if case .transfer = self.starsFilter { - let filteredGifts: [StarGift] = self.state?.transferStarGifts?.compactMap { gift in - if case .unique = gift.gift { - return gift.gift - } else { - return nil - } + let filteredGifts: [StarGift] = self.state?.transferStarGifts?.map { gift in + return gift.gift } ?? [] self._effectiveStarGifts = (filteredGifts, self.starsFilter) return filteredGifts @@ -497,7 +493,7 @@ final class GiftOptionsScreenComponent: Component { } let bottomContentOffset = max(0.0, self.scrollView.contentSize.height - self.scrollView.contentOffset.y - self.scrollView.frame.height) - if interactive, bottomContentOffset < 200.0, case .transfer = self.starsFilter { + if interactive, bottomContentOffset < 320.0, case .transfer = self.starsFilter { self.state?.starGiftsContext.loadMore() } } @@ -1348,7 +1344,7 @@ final class GiftOptionsScreenComponent: Component { ) { self.context = context - self.starGiftsContext = ProfileGiftsContext(account: context.account, peerId: context.account.peerId) + self.starGiftsContext = ProfileGiftsContext(account: context.account, peerId: context.account.peerId, filter: [.unique, .displayed, .hidden]) super.init() @@ -1380,8 +1376,11 @@ final class GiftOptionsScreenComponent: Component { } self.peer = peer - self.disallowedGifts = disallowedGifts ?? [] - + if peerId == context.account.peerId { + self.disallowedGifts = [] + } else { + self.disallowedGifts = disallowedGifts ?? [] + } if peerId != context.account.peerId { if availableProducts.isEmpty { var premiumProducts: [PremiumGiftProduct] = [] @@ -1434,7 +1433,7 @@ final class GiftOptionsScreenComponent: Component { if let disallowedGifts, disallowedGifts.contains(.unique) { } else { - self.transferStarGifts = profileGiftsState.gifts.compactMap { gift in + self.transferStarGifts = profileGiftsState.filteredGifts.compactMap { gift in if case .unique = gift.gift { return gift } else { diff --git a/submodules/TelegramUI/Sources/SharedAccountContext.swift b/submodules/TelegramUI/Sources/SharedAccountContext.swift index c20e6b8ea8..6a223c5277 100644 --- a/submodules/TelegramUI/Sources/SharedAccountContext.swift +++ b/submodules/TelegramUI/Sources/SharedAccountContext.swift @@ -2796,7 +2796,7 @@ public final class SharedAccountContextImpl: SharedAccountContext { } else { let _ = (context.engine.data.get(TelegramEngine.EngineData.Item.Peer.DisallowedGifts(id: peer.id)) |> deliverOnMainQueue).start(next: { disallowedGifts in - if let disallowedGifts, disallowedGifts == TelegramDisallowedGifts.All { + if let disallowedGifts, disallowedGifts == TelegramDisallowedGifts.All && peer.id != context.account.peerId { let alertController = textAlertController(context: context, title: nil, text: presentationData.strings.Gift_Send_GiftsDisallowed(EnginePeer(peer).compactDisplayTitle).string, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]) controller?.present(alertController, in: .window(.root)) return