diff --git a/TelegramCore/UpdatePeers.swift b/TelegramCore/UpdatePeers.swift index 5b49f27616..49b41a7529 100644 --- a/TelegramCore/UpdatePeers.swift +++ b/TelegramCore/UpdatePeers.swift @@ -80,7 +80,14 @@ public func updatePeers(transaction: Transaction, peers: [Peer], update: (Peer?, } case Namespaces.Peer.SecretChat: if let secretChat = updated as? TelegramSecretChat { - updatePeerChatInclusionWithMinTimestamp(transaction: transaction, id: peerId, minTimestamp: secretChat.creationDate, forceRootGroupIfNotExists: true) + let isActive: Bool + switch secretChat.embeddedState { + case .active, .handshake: + isActive = true + case .terminated: + isActive = false + } + updatePeerChatInclusionWithMinTimestamp(transaction: transaction, id: peerId, minTimestamp: secretChat.creationDate, forceRootGroupIfNotExists: isActive) } else { assertionFailure() }