mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various improvements
This commit is contained in:
parent
2acb93f386
commit
390a5e6376
@ -1947,19 +1947,6 @@ public final class ChatListNode: ListView {
|
||||
|
||||
if suggestions.contains(.setupBirthday) && birthday == nil {
|
||||
return .single(.setupBirthday)
|
||||
} else if !todayBirthdayPeerIds.isEmpty && todayBirthdayPeerIds.map({ $0.toInt64() }) != dismissedBirthdayPeerIds {
|
||||
return context.engine.data.get(
|
||||
EngineDataMap(todayBirthdayPeerIds.map(TelegramEngine.EngineData.Item.Peer.Peer.init(id:)))
|
||||
)
|
||||
|> map { result -> ChatListNotice? in
|
||||
var todayBirthdayPeers: [EnginePeer] = []
|
||||
for (peerId, _) in birthdays {
|
||||
if let maybePeer = result[peerId], let peer = maybePeer {
|
||||
todayBirthdayPeers.append(peer)
|
||||
}
|
||||
}
|
||||
return .birthdayPremiumGift(peers: todayBirthdayPeers, birthdays: birthdays)
|
||||
}
|
||||
} else if suggestions.contains(.xmasPremiumGift) {
|
||||
return .single(.xmasPremiumGift)
|
||||
} else if suggestions.contains(.annualPremium) || suggestions.contains(.upgradePremium) || suggestions.contains(.restorePremium), let inAppPurchaseManager = context.inAppPurchaseManager {
|
||||
@ -1988,12 +1975,33 @@ public final class ChatListNode: ListView {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
} else {
|
||||
if !GlobalExperimentalSettings.isAppStoreBuild {
|
||||
if suggestions.contains(.restorePremium) {
|
||||
return .premiumRestore(discount: 0)
|
||||
} else if suggestions.contains(.annualPremium) {
|
||||
return .premiumAnnualDiscount(discount: 0)
|
||||
} else if suggestions.contains(.upgradePremium) {
|
||||
return .premiumUpgrade(discount: 0)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
} else if !todayBirthdayPeerIds.isEmpty && todayBirthdayPeerIds.map({ $0.toInt64() }) != dismissedBirthdayPeerIds {
|
||||
return context.engine.data.get(
|
||||
EngineDataMap(todayBirthdayPeerIds.map(TelegramEngine.EngineData.Item.Peer.Peer.init(id:)))
|
||||
)
|
||||
|> map { result -> ChatListNotice? in
|
||||
var todayBirthdayPeers: [EnginePeer] = []
|
||||
for (peerId, _) in birthdays {
|
||||
if let maybePeer = result[peerId], let peer = maybePeer {
|
||||
todayBirthdayPeers.append(peer)
|
||||
}
|
||||
}
|
||||
return .birthdayPremiumGift(peers: todayBirthdayPeers, birthdays: birthdays)
|
||||
}
|
||||
} else {
|
||||
return .single(nil)
|
||||
}
|
||||
|
@ -569,7 +569,11 @@ private func contactListNodeEntries(accountPeer: EnginePeer?, peers: [ContactLis
|
||||
} else {
|
||||
allSelected = false
|
||||
}
|
||||
let header: ListViewItemHeader? = ChatListSearchItemHeader(type: .text(title.uppercased(), AnyHashable(10 * sectionId + (allSelected ? 1 : 0))), theme: theme, strings: strings, actionTitle: allSelected ? strings.Premium_Gift_ContactSelection_DeselectAll.uppercased() : strings.Premium_Gift_ContactSelection_SelectAll.uppercased(), action: {
|
||||
var actionTitle: String?
|
||||
if peerIds.count > 1 {
|
||||
actionTitle = allSelected ? strings.Premium_Gift_ContactSelection_DeselectAll.uppercased() : strings.Premium_Gift_ContactSelection_SelectAll.uppercased()
|
||||
}
|
||||
let header: ListViewItemHeader? = ChatListSearchItemHeader(type: .text(title.uppercased(), AnyHashable(10 * sectionId + (allSelected ? 1 : 0))), theme: theme, strings: strings, actionTitle: actionTitle, action: {
|
||||
interaction.toggleSelection(topPeers.filter { peerIds.contains($0.id) }, !allSelected)
|
||||
})
|
||||
|
||||
@ -596,7 +600,26 @@ private func contactListNodeEntries(accountPeer: EnginePeer?, peers: [ContactLis
|
||||
sectionId += 1
|
||||
}
|
||||
|
||||
let hasDeselectAll = !(selectionState?.selectedPeerIndices ?? [:]).isEmpty
|
||||
var hasDeselectAll = !(selectionState?.selectedPeerIndices ?? [:]).isEmpty
|
||||
if !sections.isEmpty, let selectionState {
|
||||
var hasNonBirthdayPeers = false
|
||||
var allBirthdayPeerIds = Set<EnginePeer.Id>()
|
||||
for (_, peerIds) in sections {
|
||||
for peerId in peerIds {
|
||||
allBirthdayPeerIds.insert(peerId)
|
||||
}
|
||||
}
|
||||
for id in selectionState.selectedPeerIndices.keys {
|
||||
if case let .peer(peerId) = id, !allBirthdayPeerIds.contains(peerId) {
|
||||
hasNonBirthdayPeers = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !hasNonBirthdayPeers {
|
||||
hasDeselectAll = false
|
||||
}
|
||||
}
|
||||
|
||||
let header: ListViewItemHeader? = ChatListSearchItemHeader(type: .text(strings.Premium_Gift_ContactSelection_FrequentContacts.uppercased(), AnyHashable(hasDeselectAll ? 1 : 0)), theme: theme, strings: strings, actionTitle: hasDeselectAll ? strings.Premium_Gift_ContactSelection_DeselectAll.uppercased() : nil, action: {
|
||||
interaction.deselectAll()
|
||||
})
|
||||
|
@ -48,6 +48,7 @@ public final class ListSectionHeaderNode: ASDisplayNode {
|
||||
if (self.action != nil) != (self.actionButton != nil) {
|
||||
if let _ = self.action {
|
||||
let actionButtonLabel = ImmediateTextNode()
|
||||
actionButtonLabel.displaysAsynchronously = false
|
||||
self.addSubnode(actionButtonLabel)
|
||||
self.actionButtonLabel = actionButtonLabel
|
||||
let actionButton = HighlightableButtonNode()
|
||||
|
Loading…
x
Reference in New Issue
Block a user