From 0bd2b7d82d6b494b2805a08c9a6773a255d946a1 Mon Sep 17 00:00:00 2001 From: fmodf Date: Mon, 7 Oct 2024 19:10:03 +0200 Subject: [PATCH] wip --- ConversationsClassic/AppData/Model/Credentials.swift | 9 +++++++++ .../View/Main/Settings/SettingsScreen.swift | 6 ++++++ 2 files changed, 15 insertions(+) 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)")