diff --git a/ConversationsClassic/AppData/Store/GlobalSettingsStore.swift b/ConversationsClassic/AppData/Store/GlobalSettingsStore.swift deleted file mode 100644 index e969c79..0000000 --- a/ConversationsClassic/AppData/Store/GlobalSettingsStore.swift +++ /dev/null @@ -1,32 +0,0 @@ -import Combine -import Foundation -import GRDB -import Photos -import SwiftUI - -@MainActor -final class GlobalSettingsStore: ObservableObject { - static let shared = GlobalSettingsStore() - - @Published var credentials: [Credentials] = [] - - private var credentialsCancellable: AnyCancellable? - - init() { - subscribe() - } -} - -private extension GlobalSettingsStore { - func subscribe() { - credentialsCancellable = ValueObservation.tracking(Credentials - .fetchAll - ) - .publisher(in: Database.shared.dbQueue, scheduling: .immediate) - .receive(on: DispatchQueue.main) - .sink { _ in - } receiveValue: { [weak self] credentials in - self?.credentials = credentials - } - } -} diff --git a/ConversationsClassic/ConversationsClassicApp.swift b/ConversationsClassic/ConversationsClassicApp.swift index 4816a3f..bf24165 100644 --- a/ConversationsClassic/ConversationsClassicApp.swift +++ b/ConversationsClassic/ConversationsClassicApp.swift @@ -5,7 +5,6 @@ import SwiftUI @MainActor struct ConversationsClassic: App { private let clientsStore = ClientsStore.shared - private let globalSettingsStore = GlobalSettingsStore.shared init() { // There's a bug on iOS 17 where sheet may not load with large title, even if modifiers are set, which causes some tests to fail @@ -17,7 +16,6 @@ struct ConversationsClassic: App { WindowGroup { RootView() .environmentObject(clientsStore) - .environmentObject(globalSettingsStore) } } } diff --git a/ConversationsClassic/View/Entering/WelcomeScreen.swift b/ConversationsClassic/View/Entering/WelcomeScreen.swift index 31ab60a..90d1294 100644 --- a/ConversationsClassic/View/Entering/WelcomeScreen.swift +++ b/ConversationsClassic/View/Entering/WelcomeScreen.swift @@ -1,7 +1,7 @@ import SwiftUI struct WelcomeScreen: View { - @EnvironmentObject var globalSettingsStore: GlobalSettingsStore + @EnvironmentObject var clientsStore: ClientsStore @Environment(\.router) var router var body: some View { @@ -10,22 +10,22 @@ struct WelcomeScreen: View { Color.Material.Background.light .ignoresSafeArea() - if !globalSettingsStore.credentials.isEmpty && globalSettingsStore.credentials.allSatisfy({ !$0.isActive }) { - VStack { - HStack { - Spacer() - Image(systemName: "gear") - .foregroundColor(.Material.Elements.active) - .tappablePadding(.symmetric(10)) { - router.showScreen(.push) { _ in - SettingsScreen() - } - } - } - .padding() - Spacer() - } - } + // if !clientsStore.clients.isEmpty && clientsStore.clients.allSatisfy({ $0.state != .enabled(.connected) }) { + // VStack { + // HStack { + // Spacer() + // Image(systemName: "gear") + // .foregroundColor(.Material.Elements.active) + // .tappablePadding(.symmetric(10)) { + // router.showScreen(.push) { _ in + // SettingsScreen() + // } + // } + // } + // .padding() + // Spacer() + // } + // } // content VStack(spacing: 32) { diff --git a/ConversationsClassic/View/Main/Settings/SettingsScreen.swift b/ConversationsClassic/View/Main/Settings/SettingsScreen.swift index 10c02c3..5537ea7 100644 --- a/ConversationsClassic/View/Main/Settings/SettingsScreen.swift +++ b/ConversationsClassic/View/Main/Settings/SettingsScreen.swift @@ -2,7 +2,6 @@ import SwiftUI struct SettingsScreen: View { @EnvironmentObject var clientsStore: ClientsStore - @EnvironmentObject var settingsStore: GlobalSettingsStore @Environment(\.router) var router var body: some View { @@ -23,23 +22,23 @@ struct SettingsScreen: View { // Accounts section SharedSectionTitle(text: L10n.Settings.Section.Accounts.title) - ForEach(settingsStore.credentials) { creds in - SharedListRow( - iconType: .charCircle(creds.bareJid), - text: creds.bareJid, - controlType: .switcher(isOn: Binding( - get: { creds.isActive }, - set: { new in - Task { - try? await creds.setActive(flag: new) - } - } - )) - ) - .onTapGesture { - print("Tapped account \(creds.bareJid)") - } - } + // ForEach(settingsStore.credentials) { creds in + // SharedListRow( + // iconType: .charCircle(creds.bareJid), + // text: creds.bareJid, + // controlType: .switcher(isOn: Binding( + // get: { creds.isActive }, + // set: { new in + // Task { + // try? await creds.setActive(flag: new) + // } + // } + // )) + // ) + // .onTapGesture { + // print("Tapped account \(creds.bareJid)") + // } + // } SharedListRow( iconType: .image(Image(systemName: "plus"), .Material.Elements.active), diff --git a/ConversationsClassic/View/RootView.swift b/ConversationsClassic/View/RootView.swift index 2460c56..61b3638 100644 --- a/ConversationsClassic/View/RootView.swift +++ b/ConversationsClassic/View/RootView.swift @@ -3,12 +3,11 @@ import SwiftUI struct RootView: View { @EnvironmentObject var clientsStore: ClientsStore - @EnvironmentObject var globalSettingsStore: GlobalSettingsStore var body: some View { Group { if clientsStore.ready { - if clientsStore.clients.isEmpty || globalSettingsStore.credentials.allSatisfy({ !$0.isActive }) { + if clientsStore.clients.isEmpty { RouterView { _ in WelcomeScreen() }