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