Merge branch 'master' into experimental-2

This commit is contained in:
Ali
2021-08-25 00:22:17 +02:00
306 changed files with 10011 additions and 3328 deletions

View File

@@ -1412,9 +1412,7 @@ private func finalStateWithUpdatesAndServerTime(postbox: Postbox, network: Netwo
}
updatedState.deleteMessages(messageIds)
case let .updateTheme(theme):
if let theme = TelegramTheme(apiTheme: theme) {
updatedState.updateTheme(theme)
}
updatedState.updateTheme(TelegramTheme(apiTheme: theme))
case let .updateMessageID(id, randomId):
updatedState.updatedOutgoingUniqueMessageIds[randomId] = id
case .updateDialogFilters:
@@ -2255,7 +2253,7 @@ private func recordPeerActivityTimestamp(peerId: PeerId, timestamp: Int32, into
}
}
func replayFinalState(accountManager: AccountManager, postbox: Postbox, accountPeerId: PeerId, mediaBox: MediaBox, encryptionProvider: EncryptionProvider, transaction: Transaction, auxiliaryMethods: AccountAuxiliaryMethods, finalState: AccountFinalState, removePossiblyDeliveredMessagesUniqueIds: [Int64: PeerId]) -> AccountReplayedFinalState? {
func replayFinalState(accountManager: AccountManager<TelegramAccountManagerTypes>, postbox: Postbox, accountPeerId: PeerId, mediaBox: MediaBox, encryptionProvider: EncryptionProvider, transaction: Transaction, auxiliaryMethods: AccountAuxiliaryMethods, finalState: AccountFinalState, removePossiblyDeliveredMessagesUniqueIds: [Int64: PeerId]) -> AccountReplayedFinalState? {
let verified = verifyTransaction(transaction, finalState: finalState.state)
if !verified {
Logger.shared.log("State", "failed to verify final state")
@@ -2449,6 +2447,28 @@ func replayFinalState(accountManager: AccountManager, postbox: Postbox, accountP
})
}
switch action.action {
case let .setChatTheme(emoji):
transaction.updatePeerCachedData(peerIds: [message.id.peerId], update: { peerId, current in
var current = current
if current == nil {
if peerId.namespace == Namespaces.Peer.CloudUser {
current = CachedUserData()
} else if peerId.namespace == Namespaces.Peer.CloudGroup {
current = CachedGroupData()
} else if peerId.namespace == Namespaces.Peer.CloudChannel {
current = CachedChannelData()
}
}
if let cachedData = current as? CachedUserData {
return cachedData.withUpdatedThemeEmoticon(!emoji.isEmpty ? emoji : nil)
} else if let cachedData = current as? CachedGroupData {
return cachedData.withUpdatedThemeEmoticon(!emoji.isEmpty ? emoji : nil)
} else if let cachedData = current as? CachedChannelData {
return cachedData.withUpdatedThemeEmoticon(!emoji.isEmpty ? emoji : nil)
} else {
return current
}
})
case .groupCreated, .channelMigratedFromGroup:
let holesAtHistoryStart = transaction.getHole(containing: MessageId(peerId: chatPeerId, namespace: Namespaces.Message.Cloud, id: id.id - 1))
for (space, _) in holesAtHistoryStart {