Skip to content

Commit 3b7ddc3

Browse files
committed
Merge commit '0401bc8ef1ac1ea2038e4c986072d4cb52ecb4b6' into beta
2 parents 4882a3b + 0401bc8 commit 3b7ddc3

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

submodules/TelegramCore/Sources/TelegramEngine/Payments/StarGifts.swift

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,10 +1152,12 @@ private final class ProfileGiftsContextImpl {
11521152
self.filteredGifts = []
11531153
self.filteredCount = nil
11541154
}
1155+
let isUniqueOnlyFilter = self.filter == [.unique, .displayed, .hidden]
1156+
11551157
let dataState = isFiltered ? self.filteredDataState : self.dataState
11561158

11571159
if case let .ready(true, initialNextOffset) = dataState {
1158-
if !isFiltered, self.gifts.isEmpty, initialNextOffset == nil, !reload {
1160+
if !isFiltered || isUniqueOnlyFilter, self.gifts.isEmpty, initialNextOffset == nil, !reload {
11591161
self.cacheDisposable.set((self.account.postbox.transaction { transaction -> CachedProfileGifts? in
11601162
let cachedGifts = transaction.retrieveItemCacheEntry(id: entryId(peerId: peerId))?.get(CachedProfileGifts.self)
11611163
cachedGifts?.render(transaction: transaction)
@@ -1164,7 +1166,22 @@ private final class ProfileGiftsContextImpl {
11641166
guard let self, let cachedGifts else {
11651167
return
11661168
}
1167-
if case .loading = self.dataState {
1169+
if isUniqueOnlyFilter, case .loading = self.filteredDataState {
1170+
var gifts = cachedGifts.gifts
1171+
if isUniqueOnlyFilter {
1172+
gifts = gifts.filter({ gift in
1173+
if case .unique = gift.gift {
1174+
return true
1175+
} else {
1176+
return false
1177+
}
1178+
})
1179+
}
1180+
self.gifts = gifts
1181+
self.count = cachedGifts.count
1182+
self.notificationsEnabled = cachedGifts.notificationsEnabled
1183+
self.pushState()
1184+
} else if case .loading = self.dataState {
11681185
self.gifts = cachedGifts.gifts
11691186
self.count = cachedGifts.count
11701187
self.notificationsEnabled = cachedGifts.notificationsEnabled

submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,22 @@ final class GiftOptionsScreenComponent: Component {
601601
return
602602
}
603603

604+
let currentTime = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
605+
if let canTransferDate = gift.canTransferDate, currentTime < canTransferDate {
606+
let dateString = stringForFullDate(timestamp: canTransferDate, strings: environment.strings, dateTimeFormat: environment.dateTimeFormat)
607+
let alertController = textAlertController(
608+
context: component.context,
609+
title: environment.strings.Gift_Transfer_Unavailable_Title,
610+
text: environment.strings.Gift_Transfer_Unavailable_Text(dateString).string,
611+
actions: [
612+
TextAlertAction(type: .defaultAction, title: environment.strings.Common_OK, action: {})
613+
],
614+
parseMarkdown: true
615+
)
616+
controller.present(alertController, in: .window(.root))
617+
return
618+
}
619+
604620
let mainController: ViewController
605621
if let parentController = controller.parentController() {
606622
mainController = parentController

submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftViewScreen.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,8 @@ private final class GiftViewSheetContent: CombinedComponent {
12171217
parseMarkdown: true
12181218
)
12191219
controller.present(alertController, in: .window(.root))
1220+
1221+
HapticFeedback().error()
12201222
default:
12211223
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)
12221224
controller.present(alertController, in: .window(.root))

0 commit comments

Comments
 (0)