mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
f68632cb36
commit
75f7d3e2fb
@ -354,14 +354,26 @@ func chatContextMenuItems(context: AccountContext, peerId: PeerId, promoInfo: Ch
|
|||||||
case let .limitExceeded(count, _):
|
case let .limitExceeded(count, _):
|
||||||
f(.default)
|
f(.default)
|
||||||
|
|
||||||
var replaceImpl: ((ViewController) -> Void)?
|
if case .filter = location {
|
||||||
let controller = PremiumLimitScreen(context: context, subject: .pins, count: Int32(count), action: {
|
var replaceImpl: ((ViewController) -> Void)?
|
||||||
let premiumScreen = PremiumIntroScreen(context: context, source: .pinnedChats)
|
let controller = PremiumLimitScreen(context: context, subject: .chatsPerFolder, count: Int32(count), action: {
|
||||||
replaceImpl?(premiumScreen)
|
let premiumScreen = PremiumIntroScreen(context: context, source: .pinnedChats)
|
||||||
})
|
replaceImpl?(premiumScreen)
|
||||||
chatListController?.push(controller)
|
})
|
||||||
replaceImpl = { [weak controller] c in
|
chatListController?.push(controller)
|
||||||
controller?.replace(with: c)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -2,7 +2,6 @@ import Foundation
|
|||||||
import Postbox
|
import Postbox
|
||||||
import SwiftSignalKit
|
import SwiftSignalKit
|
||||||
|
|
||||||
|
|
||||||
public enum TogglePeerChatPinnedLocation {
|
public enum TogglePeerChatPinnedLocation {
|
||||||
case group(PeerGroupId)
|
case group(PeerGroupId)
|
||||||
case filter(Int32)
|
case filter(Int32)
|
||||||
@ -17,6 +16,10 @@ func _internal_toggleItemPinned(postbox: Postbox, accountPeerId: PeerId, locatio
|
|||||||
return postbox.transaction { transaction -> TogglePeerChatPinnedResult in
|
return postbox.transaction { transaction -> TogglePeerChatPinnedResult in
|
||||||
let isPremium = transaction.getPeer(accountPeerId)?.isPremium ?? false
|
let isPremium = transaction.getPeer(accountPeerId)?.isPremium ?? false
|
||||||
|
|
||||||
|
let appConfiguration = transaction.getPreferencesEntry(key: PreferencesKeys.appConfiguration)?.get(AppConfiguration.self) ?? .defaultValue
|
||||||
|
let limitsConfiguration = transaction.getPreferencesEntry(key: PreferencesKeys.limitsConfiguration)?.get(LimitsConfiguration.self) ?? LimitsConfiguration.defaultValue
|
||||||
|
let userLimitsConfiguration = UserLimitsConfiguration(appConfiguration: appConfiguration, isPremium: isPremium)
|
||||||
|
|
||||||
switch location {
|
switch location {
|
||||||
case let .group(groupId):
|
case let .group(groupId):
|
||||||
var itemIds = transaction.getPinnedItemIds(groupId: groupId)
|
var itemIds = transaction.getPinnedItemIds(groupId: groupId)
|
||||||
@ -39,9 +42,8 @@ func _internal_toggleItemPinned(postbox: Postbox, accountPeerId: PeerId, locatio
|
|||||||
additionalCount = 1
|
additionalCount = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
let appConfiguration = transaction.getPreferencesEntry(key: PreferencesKeys.appConfiguration)?.get(AppConfiguration.self) ?? .defaultValue
|
|
||||||
let limitsConfiguration = transaction.getPreferencesEntry(key: PreferencesKeys.limitsConfiguration)?.get(LimitsConfiguration.self) ?? LimitsConfiguration.defaultValue
|
|
||||||
let userLimitsConfiguration = UserLimitsConfiguration(appConfiguration: appConfiguration, isPremium: isPremium)
|
|
||||||
|
|
||||||
let limitCount: Int
|
let limitCount: Int
|
||||||
if case .root = groupId {
|
if case .root = groupId {
|
||||||
@ -75,7 +77,7 @@ func _internal_toggleItemPinned(postbox: Postbox, accountPeerId: PeerId, locatio
|
|||||||
updatedData.includePeers.removePinnedPeer(peerId)
|
updatedData.includePeers.removePinnedPeer(peerId)
|
||||||
} else {
|
} else {
|
||||||
if !updatedData.includePeers.addPinnedPeer(peerId) {
|
if !updatedData.includePeers.addPinnedPeer(peerId) {
|
||||||
result = .limitExceeded(count: updatedData.includePeers.pinnedPeers.count, limit: 100)
|
result = .limitExceeded(count: updatedData.includePeers.peers.count, limit: Int(userLimitsConfiguration.maxFolderChatsCount))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
filters[index] = .filter(id: id, title: title, emoticon: emoticon, data: updatedData)
|
filters[index] = .filter(id: id, title: title, emoticon: emoticon, data: updatedData)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user