diff --git a/ConversationsClassic/AppData/Client/Client.swift b/ConversationsClassic/AppData/Client/Client.swift index 13398c5..59507c0 100644 --- a/ConversationsClassic/AppData/Client/Client.swift +++ b/ConversationsClassic/AppData/Client/Client.swift @@ -76,6 +76,10 @@ extension Client: Identifiable { } extension Client { + func updActivity(_ isActive: Bool) async { + credentials.isActive = isActive + } + func addRoster(_ jid: String, name: String?, groups: [String]) async throws { _ = try await connection.module(.roster).addItem( jid: JID(jid), diff --git a/ConversationsClassic/AppData/Store/ClientsStore.swift b/ConversationsClassic/AppData/Store/ClientsStore.swift index b3f07f7..a1d7a25 100644 --- a/ConversationsClassic/AppData/Store/ClientsStore.swift +++ b/ConversationsClassic/AppData/Store/ClientsStore.swift @@ -48,11 +48,13 @@ final class ClientsStore: ObservableObject { updatedClients.append(contentsOf: newClients) clients = updatedClients - // for creds in credentials { - // if let client = client(for: creds) { - // client.credentials = creds - // } - // } + Task { + for client in clients { + if let creds = credentials.first(where: { $0.bareJid == client.credentials.bareJid }) { + await client.updActivity(creds.isActive) + } + } + } if !ready { ready = true diff --git a/ConversationsClassic/View/Main/Settings/SettingsScreen.swift b/ConversationsClassic/View/Main/Settings/SettingsScreen.swift index e0cd742..9e6e7cd 100644 --- a/ConversationsClassic/View/Main/Settings/SettingsScreen.swift +++ b/ConversationsClassic/View/Main/Settings/SettingsScreen.swift @@ -85,11 +85,6 @@ struct SettingsScreen: View { Spacer() } } - // .onDisappear { - // if settingsStore.credentials.isEmpty || settingsStore.credentials.allSatisfy({ !$0.isActive }) { - // router.dismissScreenStack() - // } - // } } @ViewBuilder private var addAccountSelector: some View {