diff --git a/ConversationsClassic/AppData/Model/Credentials.swift b/ConversationsClassic/AppData/Model/Credentials.swift index 32cca11..c40920e 100644 --- a/ConversationsClassic/AppData/Model/Credentials.swift +++ b/ConversationsClassic/AppData/Model/Credentials.swift @@ -24,6 +24,15 @@ struct Credentials: DBStorable, Hashable { try self.delete(db) } } + + func setActive(flag: Bool) async throws { + let db = Database.shared.dbQueue + _ = try await db.write { db in + var updated = self + updated.isActive = flag + try updated.save(db) + } + } } extension Credentials: UniversalInputSelectionElement { diff --git a/ConversationsClassic/View/Main/Settings/SettingsScreen.swift b/ConversationsClassic/View/Main/Settings/SettingsScreen.swift index c925cb1..413573b 100644 --- a/ConversationsClassic/View/Main/Settings/SettingsScreen.swift +++ b/ConversationsClassic/View/Main/Settings/SettingsScreen.swift @@ -27,6 +27,12 @@ struct SettingsScreen: View { iconType: .charCircle(client.credentials.bareJid), text: client.credentials.bareJid, controlType: .none + // controlType: .switcher(isOn: Binding( + // get: { client.credentials.isActive }, + // set: { new in + // client.setActive(new) + // } + // )) ) .onTapGesture { print("Tapped account \(client.credentials.bareJid)")