wip
This commit is contained in:
parent
e6fe7c538c
commit
841387aab7
|
@ -82,6 +82,9 @@ extension Client {
|
||||||
try? await credentials.setActive(flag: isActive)
|
try? await credentials.setActive(flag: isActive)
|
||||||
if isActive {
|
if isActive {
|
||||||
self.state = .enabled(.disconnected)
|
self.state = .enabled(.disconnected)
|
||||||
|
} else {
|
||||||
|
self.state = .disabled
|
||||||
|
self.disconnect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,6 +236,12 @@ private extension ClientsStore {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extension ClientsStore {
|
||||||
|
func reconnectOnActiveState() {
|
||||||
|
reconnectNeeded()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Remove all data for debug
|
// MARK: - Remove all data for debug
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
extension ClientsStore {
|
extension ClientsStore {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import SwiftUI
|
||||||
@main
|
@main
|
||||||
@MainActor
|
@MainActor
|
||||||
struct ConversationsClassic: App {
|
struct ConversationsClassic: App {
|
||||||
|
@Environment(\.scenePhase) private var scenePhase
|
||||||
private let clientsStore = ClientsStore.shared
|
private let clientsStore = ClientsStore.shared
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
@ -16,6 +17,18 @@ struct ConversationsClassic: App {
|
||||||
WindowGroup {
|
WindowGroup {
|
||||||
RootView()
|
RootView()
|
||||||
.environmentObject(clientsStore)
|
.environmentObject(clientsStore)
|
||||||
|
.onChange(of: scenePhase) { phase in
|
||||||
|
switch phase {
|
||||||
|
case .active:
|
||||||
|
clientsStore.reconnectOnActiveState()
|
||||||
|
|
||||||
|
case .inactive, .background:
|
||||||
|
fallthrough
|
||||||
|
|
||||||
|
@unknown default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue