mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-15 13:35:19 +00:00
Merge commit '0401bc8ef1ac1ea2038e4c986072d4cb52ecb4b6' into beta
This commit is contained in:
commit
3b7ddc33ee
@ -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
|
||||
|
@ -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
|
||||
|
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user