mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-28 16:42:20 +00:00
ApplyUpdateMessage: search for appropriate peerId in case of multiple messages
EnqueueMessage: author in a broadcast channel is always the channel AccountStateManagementUtils: don't include the last message in the hole range
This commit is contained in:
parent
5c8d8e8d71
commit
28d971f992
@ -2545,7 +2545,12 @@ func replayFinalState(accountManager: AccountManager, postbox: Postbox, accountP
|
|||||||
}
|
}
|
||||||
|
|
||||||
for messageId in holesFromPreviousStateMeessageIds {
|
for messageId in holesFromPreviousStateMeessageIds {
|
||||||
let upperId = topUpperHistoryBlockMessages[PeerIdAndMessageNamespace(peerId: messageId.peerId, namespace: messageId.namespace)] ?? Int32.max
|
let upperId: MessageId.Id
|
||||||
|
if let value = topUpperHistoryBlockMessages[PeerIdAndMessageNamespace(peerId: messageId.peerId, namespace: messageId.namespace)], value < Int32.max {
|
||||||
|
upperId = value - 1
|
||||||
|
} else {
|
||||||
|
upperId = Int32.max
|
||||||
|
}
|
||||||
if upperId > messageId.id {
|
if upperId > messageId.id {
|
||||||
transaction.addHole(peerId: messageId.peerId, namespace: messageId.namespace, space: .everywhere, range: messageId.id ... upperId)
|
transaction.addHole(peerId: messageId.peerId, namespace: messageId.namespace, space: .everywhere, range: messageId.id ... upperId)
|
||||||
}
|
}
|
||||||
|
@ -194,8 +194,9 @@ public func addChannelMembers(account: Account, peerId: PeerId, memberIds: [Peer
|
|||||||
return .single(Void())
|
return .single(Void())
|
||||||
}
|
}
|
||||||
|
|
||||||
} |> introduceError(AddChannelMemberError.self)
|
}
|
||||||
|
|> introduceError(AddChannelMemberError.self)
|
||||||
return signal |> switchToLatest
|
|
||||||
|
|
||||||
|
return signal
|
||||||
|
|> switchToLatest
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,23 @@ func applyMediaResourceChanges(from: Media, to: Media, postbox: Postbox) {
|
|||||||
|
|
||||||
func applyUpdateMessage(postbox: Postbox, stateManager: AccountStateManager, message: Message, result: Api.Updates) -> Signal<Void, NoError> {
|
func applyUpdateMessage(postbox: Postbox, stateManager: AccountStateManager, message: Message, result: Api.Updates) -> Signal<Void, NoError> {
|
||||||
return postbox.transaction { transaction -> Void in
|
return postbox.transaction { transaction -> Void in
|
||||||
let messageId = result.rawMessageIds.first
|
let messageId: Int32?
|
||||||
let apiMessage = result.messages.first
|
var apiMessage: Api.Message?
|
||||||
|
|
||||||
|
for resultMessage in result.messages {
|
||||||
|
if let id = resultMessage.id {
|
||||||
|
if id.peerId == message.id.peerId {
|
||||||
|
apiMessage = resultMessage
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let apiMessage = apiMessage, let id = apiMessage.id {
|
||||||
|
messageId = id.id
|
||||||
|
} else {
|
||||||
|
messageId = result.rawMessageIds.first
|
||||||
|
}
|
||||||
|
|
||||||
var updatedTimestamp: Int32?
|
var updatedTimestamp: Int32?
|
||||||
if let apiMessage = apiMessage {
|
if let apiMessage = apiMessage {
|
||||||
|
@ -365,7 +365,7 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId,
|
|||||||
}
|
}
|
||||||
|
|
||||||
let authorId: PeerId?
|
let authorId: PeerId?
|
||||||
if let peer = peer as? TelegramChannel, case let .broadcast(info) = peer.info, !info.flags.contains(.messagesShouldHaveSignatures) {
|
if let peer = peer as? TelegramChannel, case let .broadcast(info) = peer.info {
|
||||||
authorId = peer.id
|
authorId = peer.id
|
||||||
} else {
|
} else {
|
||||||
authorId = account.peerId
|
authorId = account.peerId
|
||||||
@ -486,7 +486,7 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId,
|
|||||||
}
|
}
|
||||||
|
|
||||||
let authorId: PeerId?
|
let authorId: PeerId?
|
||||||
if let peer = peer as? TelegramChannel, case let .broadcast(info) = peer.info, !info.flags.contains(.messagesShouldHaveSignatures) {
|
if let peer = peer as? TelegramChannel, case .broadcast = peer.info {
|
||||||
authorId = peer.id
|
authorId = peer.id
|
||||||
} else {
|
} else {
|
||||||
authorId = account.peerId
|
authorId = account.peerId
|
||||||
|
Loading…
x
Reference in New Issue
Block a user