mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Various fixes
This commit is contained in:
parent
5d7edcf36f
commit
d25010c1cb
5 changed files with 66 additions and 36 deletions
|
|
@ -3309,7 +3309,7 @@ func resetChannels(accountPeerId: PeerId, postbox: Postbox, network: Network, pe
|
|||
|
||||
resetForumTopics.insert(peerId)
|
||||
}
|
||||
|
||||
|
||||
for message in messages {
|
||||
var peerIsForum = false
|
||||
if let peerId = message.peerId {
|
||||
|
|
@ -3943,6 +3943,7 @@ func replayFinalState(
|
|||
var updatedStarGiftAuctionState: [Int64: GiftAuctionContext.State.AuctionState] = [:]
|
||||
var updatedStarGiftAuctionMyState: [Int64: GiftAuctionContext.State.MyState] = [:]
|
||||
var updatedEmojiGameInfo: EmojiGameInfo?
|
||||
var recentlyUsedGuestChatBots = Set<PeerId>()
|
||||
|
||||
var holesFromPreviousStateMessageIds: [MessageId] = []
|
||||
var clearHolesFromPreviousStateForChannelMessagesWithPts: [PeerIdAndMessageNamespace: Int32] = [:]
|
||||
|
|
@ -4341,6 +4342,15 @@ func replayFinalState(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if message.flags.contains(.Incoming), let authorId = message.authorId {
|
||||
for attribute in message.attributes {
|
||||
if let attribute = attribute as? GuestChatMessageAttribute, attribute.peerId == accountPeerId {
|
||||
recentlyUsedGuestChatBots.insert(authorId)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if !message.flags.contains(.Incoming) && !message.flags.contains(.Unsent) {
|
||||
if message.id.peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
|
|
@ -4350,7 +4360,7 @@ func replayFinalState(
|
|||
|
||||
if !message.flags.contains(.Incoming), message.forwardInfo == nil {
|
||||
if [Namespaces.Peer.CloudGroup, Namespaces.Peer.CloudChannel].contains(message.id.peerId.namespace), let peer = transaction.getPeer(message.id.peerId), peer.isCopyProtectionEnabled {
|
||||
|
||||
|
||||
} else if message.id.peerId.namespace == Namespaces.Peer.CloudUser, let cachedUserData = transaction.getPeerCachedData(peerId: message.id.peerId) as? CachedUserData, cachedUserData.flags.contains(.copyProtectionEnabled) || cachedUserData.flags.contains(.myCopyProtectionEnabled) {
|
||||
|
||||
} else {
|
||||
|
|
@ -5867,6 +5877,10 @@ func replayFinalState(
|
|||
}
|
||||
}
|
||||
|
||||
for peerId in recentlyUsedGuestChatBots {
|
||||
_internal_addRecentlyUsedInlineBot(transaction: transaction, peerId: peerId)
|
||||
}
|
||||
|
||||
if syncAttachMenuBots {
|
||||
// addSynchronizeAttachMenuBotsOperation(transaction: transaction)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,17 +211,21 @@ func _internal_managedRecentlyUsedInlineBots(postbox: Postbox, network: Network,
|
|||
return updatedRemotePeers
|
||||
}
|
||||
|
||||
func _internal_addRecentlyUsedInlineBot(transaction: Transaction, peerId: PeerId) {
|
||||
var maxRating = 1.0
|
||||
for entry in transaction.getOrderedListItems(collectionId: Namespaces.OrderedItemList.CloudRecentInlineBots) {
|
||||
if let contents = entry.contents.get(RecentPeerItem.self) {
|
||||
maxRating = max(maxRating, contents.rating)
|
||||
}
|
||||
}
|
||||
if let entry = CodableEntry(RecentPeerItem(rating: maxRating)) {
|
||||
transaction.addOrMoveToFirstPositionOrderedItemListItem(collectionId: Namespaces.OrderedItemList.CloudRecentInlineBots, item: OrderedItemListEntry(id: RecentPeerItemId(peerId).rawValue, contents: entry), removeTailIfCountExceeds: 20)
|
||||
}
|
||||
}
|
||||
|
||||
func _internal_addRecentlyUsedInlineBot(postbox: Postbox, peerId: PeerId) -> Signal<Void, NoError> {
|
||||
return postbox.transaction { transaction -> Void in
|
||||
var maxRating = 1.0
|
||||
for entry in transaction.getOrderedListItems(collectionId: Namespaces.OrderedItemList.CloudRecentInlineBots) {
|
||||
if let contents = entry.contents.get(RecentPeerItem.self) {
|
||||
maxRating = max(maxRating, contents.rating)
|
||||
}
|
||||
}
|
||||
if let entry = CodableEntry(RecentPeerItem(rating: maxRating)) {
|
||||
transaction.addOrMoveToFirstPositionOrderedItemListItem(collectionId: Namespaces.OrderedItemList.CloudRecentInlineBots, item: OrderedItemListEntry(id: RecentPeerItemId(peerId).rawValue, contents: entry), removeTailIfCountExceeds: 20)
|
||||
}
|
||||
_internal_addRecentlyUsedInlineBot(transaction: transaction, peerId: peerId)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1245,9 +1245,17 @@ final class ComposePollScreenComponent: Component {
|
|||
return
|
||||
}
|
||||
|
||||
let maxCount: Int32
|
||||
if let data = component.context.currentAppConfiguration.with({ $0 }).data, let value = data["poll_countries_max"] as? Double {
|
||||
maxCount = Int32(value)
|
||||
} else {
|
||||
maxCount = 12
|
||||
}
|
||||
|
||||
let stateContext = CountriesMultiselectionScreen.StateContext(
|
||||
context: component.context,
|
||||
subject: .countries,
|
||||
maxCount: maxCount,
|
||||
initialSelectedCountries: self.limitToCountries,
|
||||
showFragment: true
|
||||
)
|
||||
|
|
|
|||
|
|
@ -752,7 +752,7 @@ final class CountriesMultiselectionScreenComponent: Component {
|
|||
if let searchStateContext = self.searchStateContext, searchStateContext.subject == .countriesSearch(query: self.navigationTextFieldState.text) {
|
||||
} else {
|
||||
self.searchStateDisposable?.dispose()
|
||||
let searchStateContext = CountriesMultiselectionScreen.StateContext(context: component.context, subject: .countriesSearch(query: self.navigationTextFieldState.text))
|
||||
let searchStateContext = CountriesMultiselectionScreen.StateContext(context: component.context, subject: .countriesSearch(query: self.navigationTextFieldState.text), showFragment: component.stateContext.showFragment)
|
||||
var applyState = false
|
||||
self.searchStateDisposable = (searchStateContext.ready |> filter { $0 } |> take(1) |> deliverOnMainQueue).start(next: { [weak self] _ in
|
||||
guard let self else {
|
||||
|
|
@ -789,7 +789,6 @@ final class CountriesMultiselectionScreenComponent: Component {
|
|||
|
||||
var sections: [ItemLayout.Section] = []
|
||||
if let stateValue = self.effectiveStateValue {
|
||||
|
||||
var id: Int = 0
|
||||
for (_, countries) in stateValue.sections {
|
||||
sections.append(ItemLayout.Section(
|
||||
|
|
@ -1148,13 +1147,13 @@ public extension CountriesMultiselectionScreen {
|
|||
self.showFragment = showFragment
|
||||
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
var countryList = localizedCountryNamesAndCodes(strings: presentationData.strings)
|
||||
if showFragment {
|
||||
countryList.append((("Fragment", "Fragment"), "FT", [888]))
|
||||
}
|
||||
let countries = countryList.sorted { lhs, rhs in
|
||||
let countryList = localizedCountryNamesAndCodes(strings: presentationData.strings)
|
||||
var countries = countryList.sorted { lhs, rhs in
|
||||
return lhs.0.1.lowercased() < rhs.0.1.lowercased()
|
||||
}
|
||||
if showFragment, let index = countries.firstIndex(where: { $0.1 == "FR" }) {
|
||||
countries.insert((("Fragment", "Fragment"), "FT", [888]), at: index)
|
||||
}
|
||||
|
||||
switch subject {
|
||||
case .countries:
|
||||
|
|
@ -1164,7 +1163,7 @@ public extension CountriesMultiselectionScreen {
|
|||
var currentCountries: [CountryItem] = []
|
||||
for country in countries {
|
||||
let section = String(country.0.1.prefix(1)).uppercased()
|
||||
if currentSection != section {
|
||||
if currentSection != section && country.1 != "FT" {
|
||||
if let currentSection {
|
||||
sections.append((currentSection, currentCountries))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1724,27 +1724,32 @@ public final class ChatHistoryListNodeImpl: ListViewImpl, ChatHistoryNode, ChatH
|
|||
}
|
||||
|> distinctUntilChanged
|
||||
|
||||
let accountCountry: Signal<String?, NoError> = .single(nil)
|
||||
|> then(
|
||||
combineLatest(
|
||||
accountPeer
|
||||
|> map { peer -> String? in
|
||||
if case let .user(user) = peer {
|
||||
return user.phone
|
||||
} else {
|
||||
let accountCountry: Signal<String?, NoError>
|
||||
if let data = context.currentAppConfiguration.with({ $0 }).data, let country = data["phone_country_iso2"] as? String {
|
||||
accountCountry = .single(country)
|
||||
} else {
|
||||
accountCountry = .single(nil)
|
||||
|> then(
|
||||
combineLatest(
|
||||
accountPeer
|
||||
|> map { peer -> String? in
|
||||
if case let .user(user) = peer {
|
||||
return user.phone
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|> distinctUntilChanged,
|
||||
(context as! AccountContextImpl).countriesConfiguration
|
||||
)
|
||||
|> map { phone, countriesConfiguration in
|
||||
guard let phone, let (country, _) = lookupCountryIdByNumber(phone, configuration: countriesConfiguration) else {
|
||||
return nil
|
||||
}
|
||||
return country.id
|
||||
}
|
||||
|> distinctUntilChanged,
|
||||
(context as! AccountContextImpl).countriesConfiguration
|
||||
)
|
||||
|> map { phone, countriesConfiguration in
|
||||
guard let phone, let (country, _) = lookupCountryIdByNumber(phone, configuration: countriesConfiguration) else {
|
||||
return nil
|
||||
}
|
||||
return country.id
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
let topicAuthorId: Signal<EnginePeer.Id?, NoError>
|
||||
if let peerId = chatLocation.peerId, let threadId = chatLocation.threadId {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue