diff --git a/ConversationsClassic/AppData/Client/Client.swift b/ConversationsClassic/AppData/Client/Client.swift index 59507c0..bb30a14 100644 --- a/ConversationsClassic/AppData/Client/Client.swift +++ b/ConversationsClassic/AppData/Client/Client.swift @@ -78,6 +78,9 @@ extension Client: Identifiable { extension Client { func updActivity(_ isActive: Bool) async { credentials.isActive = isActive + Task { + try? await credentials.setActive(flag: isActive) + } } func addRoster(_ jid: String, name: String?, groups: [String]) async throws { diff --git a/ConversationsClassic/AppData/Store/ClientsStore.swift b/ConversationsClassic/AppData/Store/ClientsStore.swift index 17c22b8..ca8b5cf 100644 --- a/ConversationsClassic/AppData/Store/ClientsStore.swift +++ b/ConversationsClassic/AppData/Store/ClientsStore.swift @@ -48,14 +48,6 @@ final class ClientsStore: ObservableObject { updatedClients.append(contentsOf: newClients) clients = updatedClients - 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 } @@ -71,12 +63,6 @@ final class ClientsStore: ObservableObject { resubscribeRosters() resubscribeChats() reconnectNeeded() - - for client in clients where client.credentials.isActive { - print(client.credentials.bareJid) - } - - objectWillChange.send() } private func client(for credentials: Credentials) -> Client? { diff --git a/ConversationsClassic/View/Main/Settings/SettingsScreen.swift b/ConversationsClassic/View/Main/Settings/SettingsScreen.swift index 3e759ed..612d967 100644 --- a/ConversationsClassic/View/Main/Settings/SettingsScreen.swift +++ b/ConversationsClassic/View/Main/Settings/SettingsScreen.swift @@ -59,14 +59,11 @@ struct SettingsScreen: View { get: { client.credentials.isActive }, set: { new in Task { - try? await client.credentials.setActive(flag: new) + await client.updActivity(new) } } )) ) - .onTapGesture { - print("Tapped account \(client.credentials.bareJid)") - } } if parent == .main {