wip
This commit is contained in:
parent
fa0381e238
commit
444545b1d8
|
@ -105,6 +105,18 @@ extension ClientsStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension ClientsStore {
|
||||||
|
func addRosterForNewChatIfNeeded(_ chat: Chat) async throws {
|
||||||
|
let exists = try? await chat.fetchRoster()
|
||||||
|
if exists == nil {
|
||||||
|
guard let client = clients.first(where: { $0.credentials.bareJid == chat.account }) else {
|
||||||
|
throw AppError.clientNotFound
|
||||||
|
}
|
||||||
|
try await addRoster(client.credentials, contactJID: chat.participant, name: nil, groups: [])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Produce stores for conversation
|
// MARK: - Produce stores for conversation
|
||||||
extension ClientsStore {
|
extension ClientsStore {
|
||||||
func conversationStores(for roster: Roster) async throws -> (MessagesStore, AttachmentsStore) {
|
func conversationStores(for roster: Roster) async throws -> (MessagesStore, AttachmentsStore) {
|
||||||
|
|
|
@ -60,6 +60,7 @@ private struct ChatsRow: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
|
try? await clientsStore.addRosterForNewChatIfNeeded(chat)
|
||||||
let (messages, attachments) = try await clientsStore.conversationStores(for: chat)
|
let (messages, attachments) = try await clientsStore.conversationStores(for: chat)
|
||||||
router.showScreen(.push) { _ in
|
router.showScreen(.push) { _ in
|
||||||
ConversationScreen(messagesStore: messages, attachments: attachments)
|
ConversationScreen(messagesStore: messages, attachments: attachments)
|
||||||
|
|
Loading…
Reference in a new issue