mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Fix pinning in folders
This commit is contained in:
@@ -354,25 +354,36 @@ func chatContextMenuItems(context: AccountContext, peerId: PeerId, promoInfo: Ch
|
||||
case let .limitExceeded(count, _):
|
||||
f(.default)
|
||||
|
||||
if case .filter = location {
|
||||
var replaceImpl: ((ViewController) -> Void)?
|
||||
let controller = PremiumLimitScreen(context: context, subject: .chatsPerFolder, count: Int32(count), action: {
|
||||
let premiumScreen = PremiumIntroScreen(context: context, source: .pinnedChats)
|
||||
replaceImpl?(premiumScreen)
|
||||
})
|
||||
chatListController?.push(controller)
|
||||
replaceImpl = { [weak controller] c in
|
||||
controller?.replace(with: c)
|
||||
let isPremium = limitsData.0?.isPremium ?? false
|
||||
if isPremium {
|
||||
if case .filter = location {
|
||||
let controller = PremiumLimitScreen(context: context, subject: .chatsPerFolder, count: Int32(count), action: {})
|
||||
chatListController?.push(controller)
|
||||
} else {
|
||||
let controller = PremiumLimitScreen(context: context, subject: .pins, count: Int32(count), action: {})
|
||||
chatListController?.push(controller)
|
||||
}
|
||||
} else {
|
||||
var replaceImpl: ((ViewController) -> Void)?
|
||||
let controller = PremiumLimitScreen(context: context, subject: .pins, count: Int32(count), action: {
|
||||
let premiumScreen = PremiumIntroScreen(context: context, source: .pinnedChats)
|
||||
replaceImpl?(premiumScreen)
|
||||
})
|
||||
chatListController?.push(controller)
|
||||
replaceImpl = { [weak controller] c in
|
||||
controller?.replace(with: c)
|
||||
if case .filter = location {
|
||||
var replaceImpl: ((ViewController) -> Void)?
|
||||
let controller = PremiumLimitScreen(context: context, subject: .chatsPerFolder, count: Int32(count), action: {
|
||||
let premiumScreen = PremiumIntroScreen(context: context, source: .pinnedChats)
|
||||
replaceImpl?(premiumScreen)
|
||||
})
|
||||
chatListController?.push(controller)
|
||||
replaceImpl = { [weak controller] c in
|
||||
controller?.replace(with: c)
|
||||
}
|
||||
} else {
|
||||
var replaceImpl: ((ViewController) -> Void)?
|
||||
let controller = PremiumLimitScreen(context: context, subject: .pins, count: Int32(count), action: {
|
||||
let premiumScreen = PremiumIntroScreen(context: context, source: .pinnedChats)
|
||||
replaceImpl?(premiumScreen)
|
||||
})
|
||||
chatListController?.push(controller)
|
||||
replaceImpl = { [weak controller] c in
|
||||
controller?.replace(with: c)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -864,18 +864,35 @@ public final class ChatListNode: ListView {
|
||||
break
|
||||
case let .limitExceeded(count, _):
|
||||
if isPremium {
|
||||
let controller = PremiumLimitScreen(context: context, subject: .pins, count: Int32(count), action: {})
|
||||
strongSelf.push?(controller)
|
||||
} else {
|
||||
var replaceImpl: ((ViewController) -> Void)?
|
||||
let controller = PremiumLimitScreen(context: context, subject: .pins, count: Int32(count), action: {
|
||||
let premiumScreen = PremiumIntroScreen(context: context, source: .pinnedChats)
|
||||
replaceImpl?(premiumScreen)
|
||||
})
|
||||
replaceImpl = { [weak controller] c in
|
||||
controller?.replace(with: c)
|
||||
if case .filter = location {
|
||||
let controller = PremiumLimitScreen(context: context, subject: .chatsPerFolder, count: Int32(count), action: {})
|
||||
strongSelf.push?(controller)
|
||||
} else {
|
||||
let controller = PremiumLimitScreen(context: context, subject: .pins, count: Int32(count), action: {})
|
||||
strongSelf.push?(controller)
|
||||
}
|
||||
} else {
|
||||
if case .filter = location {
|
||||
var replaceImpl: ((ViewController) -> Void)?
|
||||
let controller = PremiumLimitScreen(context: context, subject: .chatsPerFolder, count: Int32(count), action: {
|
||||
let premiumScreen = PremiumIntroScreen(context: context, source: .pinnedChats)
|
||||
replaceImpl?(premiumScreen)
|
||||
})
|
||||
strongSelf.push?(controller)
|
||||
replaceImpl = { [weak controller] c in
|
||||
controller?.replace(with: c)
|
||||
}
|
||||
} else {
|
||||
var replaceImpl: ((ViewController) -> Void)?
|
||||
let controller = PremiumLimitScreen(context: context, subject: .pins, count: Int32(count), action: {
|
||||
let premiumScreen = PremiumIntroScreen(context: context, source: .pinnedChats)
|
||||
replaceImpl?(premiumScreen)
|
||||
})
|
||||
strongSelf.push?(controller)
|
||||
replaceImpl = { [weak controller] c in
|
||||
controller?.replace(with: c)
|
||||
}
|
||||
}
|
||||
strongSelf.push?(controller)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,13 +123,9 @@ public struct ChatListFilterIncludePeers: Equatable, Hashable {
|
||||
self.pinnedPeers.insert(peerId, at: 0)
|
||||
return true
|
||||
} else {
|
||||
if self.peers.count < 100 {
|
||||
self.peers.insert(peerId, at: 0)
|
||||
self.pinnedPeers.insert(peerId, at: 0)
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
self.peers.insert(peerId, at: 0)
|
||||
self.pinnedPeers.insert(peerId, at: 0)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,10 +213,7 @@ public struct ChatListFilterData: Equatable, Hashable {
|
||||
if self.excludePeers.contains(peerId) {
|
||||
return false
|
||||
}
|
||||
if self.excludePeers.count >= 100 {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
let _ = self.includePeers.removePeer(peerId)
|
||||
self.excludePeers.append(peerId)
|
||||
|
||||
|
||||
@@ -42,9 +42,6 @@ func _internal_toggleItemPinned(postbox: Postbox, accountPeerId: PeerId, locatio
|
||||
additionalCount = 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
let limitCount: Int
|
||||
if case .root = groupId {
|
||||
limitCount = Int(userLimitsConfiguration.maxPinnedChatCount)
|
||||
@@ -76,8 +73,10 @@ func _internal_toggleItemPinned(postbox: Postbox, accountPeerId: PeerId, locatio
|
||||
if updatedData.includePeers.pinnedPeers.contains(peerId) {
|
||||
updatedData.includePeers.removePinnedPeer(peerId)
|
||||
} else {
|
||||
if !updatedData.includePeers.addPinnedPeer(peerId) {
|
||||
let _ = updatedData.includePeers.addPinnedPeer(peerId)
|
||||
if updatedData.includePeers.peers.count > userLimitsConfiguration.maxFolderChatsCount {
|
||||
result = .limitExceeded(count: updatedData.includePeers.peers.count, limit: Int(userLimitsConfiguration.maxFolderChatsCount))
|
||||
updatedData = data
|
||||
}
|
||||
}
|
||||
filters[index] = .filter(id: id, title: title, emoticon: emoticon, data: updatedData)
|
||||
|
||||
Reference in New Issue
Block a user