diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift b/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift index d266de078e..df4b73d391 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift @@ -1152,10 +1152,12 @@ private final class ProfileGiftsContextImpl { self.filteredGifts = [] self.filteredCount = nil } + let isUniqueOnlyFilter = self.filter == [.unique, .displayed, .hidden] + let dataState = isFiltered ? self.filteredDataState : self.dataState if case let .ready(true, initialNextOffset) = dataState { - if !isFiltered, self.gifts.isEmpty, initialNextOffset == nil, !reload { + if !isFiltered || isUniqueOnlyFilter, self.gifts.isEmpty, initialNextOffset == nil, !reload { self.cacheDisposable.set((self.account.postbox.transaction { transaction -> CachedProfileGifts? in let cachedGifts = transaction.retrieveItemCacheEntry(id: entryId(peerId: peerId))?.get(CachedProfileGifts.self) cachedGifts?.render(transaction: transaction) @@ -1164,7 +1166,22 @@ private final class ProfileGiftsContextImpl { guard let self, let cachedGifts else { return } - if case .loading = self.dataState { + if isUniqueOnlyFilter, case .loading = self.filteredDataState { + var gifts = cachedGifts.gifts + if isUniqueOnlyFilter { + gifts = gifts.filter({ gift in + if case .unique = gift.gift { + return true + } else { + return false + } + }) + } + self.gifts = gifts + self.count = cachedGifts.count + self.notificationsEnabled = cachedGifts.notificationsEnabled + self.pushState() + } else if case .loading = self.dataState { self.gifts = cachedGifts.gifts self.count = cachedGifts.count self.notificationsEnabled = cachedGifts.notificationsEnabled diff --git a/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift index 643d1f7131..9ad0c55a6e 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift @@ -601,6 +601,22 @@ final class GiftOptionsScreenComponent: Component { return } + let currentTime = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970) + if let canTransferDate = gift.canTransferDate, currentTime < canTransferDate { + let dateString = stringForFullDate(timestamp: canTransferDate, strings: environment.strings, dateTimeFormat: environment.dateTimeFormat) + let alertController = textAlertController( + context: component.context, + title: environment.strings.Gift_Transfer_Unavailable_Title, + text: environment.strings.Gift_Transfer_Unavailable_Text(dateString).string, + actions: [ + TextAlertAction(type: .defaultAction, title: environment.strings.Common_OK, action: {}) + ], + parseMarkdown: true + ) + controller.present(alertController, in: .window(.root)) + return + } + let mainController: ViewController if let parentController = controller.parentController() { mainController = parentController diff --git a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift index f783f08939..2fd8a02ec2 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift @@ -1217,6 +1217,8 @@ private final class GiftViewSheetContent: CombinedComponent { parseMarkdown: true ) controller.present(alertController, in: .window(.root)) + + HapticFeedback().error() default: let alertController = textAlertController(context: context, title: nil, text: presentationData.strings.Gift_Buy_ErrorUnknown, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})], parseMarkdown: true) controller.present(alertController, in: .window(.root))