This commit is contained in:
fmodf 2024-10-20 21:28:59 +02:00
parent 78de092b06
commit 9315a89f65

View file

@ -60,10 +60,6 @@ final class ClientsStore: ObservableObject {
ready = true ready = true
} }
resubscribeRosters()
resubscribeChats()
reconnectNeeded()
if credentials.isEmpty { if credentials.isEmpty {
listState = .empty listState = .empty
} else if credentials.allSatisfy({ !$0.isActive }) { } else if credentials.allSatisfy({ !$0.isActive }) {
@ -72,6 +68,14 @@ final class ClientsStore: ObservableObject {
listState = .haveSomeEnabled listState = .haveSomeEnabled
} }
resubscribeRosters()
resubscribeChats()
reconnectNeeded()
for client in clients where client.credentials.isActive {
print(client.credentials.bareJid)
}
objectWillChange.send() objectWillChange.send()
} }
@ -198,7 +202,7 @@ extension ClientsStore {
private extension ClientsStore { private extension ClientsStore {
private func resubscribeRosters() { private func resubscribeRosters() {
let clientsJids = clients let clientsJids = clients
.filter { $0.state != .disabled } .filter { $0.credentials.isActive }
.map { $0.credentials.bareJid } .map { $0.credentials.bareJid }
rostersCancellable = ValueObservation.tracking { db in rostersCancellable = ValueObservation.tracking { db in
@ -223,7 +227,7 @@ private extension ClientsStore {
func resubscribeChats() { func resubscribeChats() {
let clientsJids = clients let clientsJids = clients
.filter { $0.state != .disabled } .filter { $0.credentials.isActive }
.map { $0.credentials.bareJid } .map { $0.credentials.bareJid }
chatsCancellable = ValueObservation.tracking { db in chatsCancellable = ValueObservation.tracking { db in