mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Fix user map
This commit is contained in:
parent
7e93b86a8b
commit
53949c8b52
@ -2098,7 +2098,7 @@ func resolveForumThreads(postbox: Postbox, network: Network, fetchedChatList: Fe
|
||||
}
|
||||
}
|
||||
|
||||
func resolveStories<T>(postbox: Postbox, source: FetchMessageHistoryHoleSource, accountPeerId: PeerId, storyIds: Set<StoryId>, result: T) -> Signal<T, NoError> {
|
||||
func resolveStories<T>(postbox: Postbox, source: FetchMessageHistoryHoleSource, accountPeerId: PeerId, storyIds: Set<StoryId>, additionalPeers: [PeerId: Peer], result: T) -> Signal<T, NoError> {
|
||||
var storyBuckets: [PeerId: [Int32]] = [:]
|
||||
for id in storyIds {
|
||||
if storyBuckets[id.peerId] == nil {
|
||||
@ -2113,7 +2113,7 @@ func resolveStories<T>(postbox: Postbox, source: FetchMessageHistoryHoleSource,
|
||||
while idOffset < allIds.count {
|
||||
let bucketLength = min(100, allIds.count - idOffset)
|
||||
let ids = Array(allIds[idOffset ..< (idOffset + bucketLength)])
|
||||
signals.append(_internal_getStoriesById(accountPeerId: accountPeerId, postbox: postbox, source: source, peerId: peerId, ids: ids)
|
||||
signals.append(_internal_getStoriesById(accountPeerId: accountPeerId, postbox: postbox, source: source, peerId: peerId, peerReference: additionalPeers[peerId].flatMap(PeerReference.init), ids: ids)
|
||||
|> mapToSignal { result -> Signal<Never, NoError> in
|
||||
return postbox.transaction { transaction -> Void in
|
||||
for id in ids {
|
||||
@ -2166,7 +2166,7 @@ func resolveAssociatedStories(postbox: Postbox, network: Network, accountPeerId:
|
||||
}
|
||||
|
||||
if !missingStoryIds.isEmpty {
|
||||
return resolveStories(postbox: postbox, source: .network(network), accountPeerId: accountPeerId, storyIds: missingStoryIds, result: state)
|
||||
return resolveStories(postbox: postbox, source: .network(network), accountPeerId: accountPeerId, storyIds: missingStoryIds, additionalPeers: state.insertedPeers, result: state)
|
||||
} else {
|
||||
return .single(state)
|
||||
}
|
||||
@ -2174,7 +2174,7 @@ func resolveAssociatedStories(postbox: Postbox, network: Network, accountPeerId:
|
||||
|> switchToLatest
|
||||
}
|
||||
|
||||
func resolveAssociatedStories<T>(postbox: Postbox, source: FetchMessageHistoryHoleSource, accountPeerId: PeerId, messages: [StoreMessage], result: T) -> Signal<T, NoError> {
|
||||
func resolveAssociatedStories<T>(postbox: Postbox, source: FetchMessageHistoryHoleSource, accountPeerId: PeerId, messages: [StoreMessage], additionalPeers: [PeerId: Peer], result: T) -> Signal<T, NoError> {
|
||||
return postbox.transaction { transaction -> Signal<T, NoError> in
|
||||
var missingStoryIds = Set<StoryId>()
|
||||
|
||||
@ -2190,7 +2190,7 @@ func resolveAssociatedStories<T>(postbox: Postbox, source: FetchMessageHistoryHo
|
||||
}
|
||||
|
||||
if !missingStoryIds.isEmpty {
|
||||
return resolveStories(postbox: postbox, source: source, accountPeerId: accountPeerId, storyIds: missingStoryIds, result: result)
|
||||
return resolveStories(postbox: postbox, source: source, accountPeerId: accountPeerId, storyIds: missingStoryIds, additionalPeers: additionalPeers, result: result)
|
||||
} else {
|
||||
return .single(result)
|
||||
}
|
||||
@ -3298,6 +3298,8 @@ func replayFinalState(
|
||||
if let entry = CodableEntry(storyItem) {
|
||||
transaction.setStory(id: id, value: entry)
|
||||
}
|
||||
} else {
|
||||
transaction.setStory(id: id, value: CodableEntry(data: Data()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ func withResolvedAssociatedMessages<T>(postbox: Postbox, source: FetchMessageHis
|
||||
if referencedReplyIds.isEmpty && referencedGeneralIds.isEmpty {
|
||||
return resolveUnknownEmojiFiles(postbox: postbox, source: source, messages: storeMessages, reactions: [], result: Void())
|
||||
|> mapToSignal { _ -> Signal<T, NoError> in
|
||||
return resolveAssociatedStories(postbox: postbox, source: source, accountPeerId: accountPeerId, messages: storeMessages, result: Void())
|
||||
return resolveAssociatedStories(postbox: postbox, source: source, accountPeerId: accountPeerId, messages: storeMessages, additionalPeers: peers, result: Void())
|
||||
|> mapToSignal { _ -> Signal<T, NoError> in
|
||||
return postbox.transaction { transaction -> T in
|
||||
return f(transaction, [], [])
|
||||
@ -227,7 +227,14 @@ func withResolvedAssociatedMessages<T>(postbox: Postbox, source: FetchMessageHis
|
||||
|
||||
return resolveUnknownEmojiFiles(postbox: postbox, source: source, messages: storeMessages + additionalMessages, reactions: [], result: Void())
|
||||
|> mapToSignal { _ -> Signal<T, NoError> in
|
||||
return resolveAssociatedStories(postbox: postbox, source: source, accountPeerId: accountPeerId, messages: storeMessages + additionalMessages, result: Void())
|
||||
var additionalPeerMap: [PeerId: Peer] = [:]
|
||||
for (_, peer) in peers {
|
||||
additionalPeerMap[peer.id] = peer
|
||||
}
|
||||
for peer in additionalPeers {
|
||||
additionalPeerMap[peer.id] = peer
|
||||
}
|
||||
return resolveAssociatedStories(postbox: postbox, source: source, accountPeerId: accountPeerId, messages: storeMessages + additionalMessages, additionalPeers: additionalPeerMap, result: Void())
|
||||
|> mapToSignal { _ -> Signal<T, NoError> in
|
||||
return postbox.transaction { transaction -> T in
|
||||
return f(transaction, additionalPeers, additionalMessages)
|
||||
|
@ -1263,12 +1263,12 @@ func _internal_getStoriesById(accountPeerId: PeerId, postbox: Postbox, network:
|
||||
}
|
||||
}
|
||||
|
||||
func _internal_getStoriesById(accountPeerId: PeerId, postbox: Postbox, source: FetchMessageHistoryHoleSource, peerId: PeerId, ids: [Int32]) -> Signal<[Stories.StoredItem], NoError> {
|
||||
func _internal_getStoriesById(accountPeerId: PeerId, postbox: Postbox, source: FetchMessageHistoryHoleSource, peerId: PeerId, peerReference: PeerReference?, ids: [Int32]) -> Signal<[Stories.StoredItem], NoError> {
|
||||
return postbox.transaction { transaction -> Api.InputUser? in
|
||||
return transaction.getPeer(peerId).flatMap(apiInputUser)
|
||||
}
|
||||
|> mapToSignal { inputUser -> Signal<[Stories.StoredItem], NoError> in
|
||||
guard let inputUser = inputUser else {
|
||||
guard let inputUser = inputUser ?? peerReference?.inputUser else {
|
||||
return .single([])
|
||||
}
|
||||
|
||||
@ -1685,7 +1685,7 @@ func _internal_exportStoryLink(account: Account, peerId: EnginePeer.Id, id: Int3
|
||||
}
|
||||
|
||||
func _internal_refreshStories(account: Account, peerId: PeerId, ids: [Int32]) -> Signal<Never, NoError> {
|
||||
return _internal_getStoriesById(accountPeerId: account.peerId, postbox: account.postbox, source: .network(account.network), peerId: peerId, ids: ids)
|
||||
return _internal_getStoriesById(accountPeerId: account.peerId, postbox: account.postbox, source: .network(account.network), peerId: peerId, peerReference: nil, ids: ids)
|
||||
|> mapToSignal { result -> Signal<Never, NoError> in
|
||||
return account.postbox.transaction { transaction -> Void in
|
||||
var currentItems = transaction.getStoryItems(peerId: peerId)
|
||||
|
Loading…
x
Reference in New Issue
Block a user