wip
This commit is contained in:
parent
6a608ead2c
commit
4f90a0d744
|
@ -78,6 +78,9 @@ extension Client: Identifiable {
|
||||||
extension Client {
|
extension Client {
|
||||||
func updActivity(_ isActive: Bool) async {
|
func updActivity(_ isActive: Bool) async {
|
||||||
credentials.isActive = isActive
|
credentials.isActive = isActive
|
||||||
|
Task {
|
||||||
|
try? await credentials.setActive(flag: isActive)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func addRoster(_ jid: String, name: String?, groups: [String]) async throws {
|
func addRoster(_ jid: String, name: String?, groups: [String]) async throws {
|
||||||
|
|
|
@ -48,14 +48,6 @@ final class ClientsStore: ObservableObject {
|
||||||
updatedClients.append(contentsOf: newClients)
|
updatedClients.append(contentsOf: newClients)
|
||||||
clients = updatedClients
|
clients = updatedClients
|
||||||
|
|
||||||
Task {
|
|
||||||
for client in clients {
|
|
||||||
if let creds = credentials.first(where: { $0.bareJid == client.credentials.bareJid }) {
|
|
||||||
await client.updActivity(creds.isActive)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if !ready {
|
if !ready {
|
||||||
ready = true
|
ready = true
|
||||||
}
|
}
|
||||||
|
@ -71,12 +63,6 @@ final class ClientsStore: ObservableObject {
|
||||||
resubscribeRosters()
|
resubscribeRosters()
|
||||||
resubscribeChats()
|
resubscribeChats()
|
||||||
reconnectNeeded()
|
reconnectNeeded()
|
||||||
|
|
||||||
for client in clients where client.credentials.isActive {
|
|
||||||
print(client.credentials.bareJid)
|
|
||||||
}
|
|
||||||
|
|
||||||
objectWillChange.send()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func client(for credentials: Credentials) -> Client? {
|
private func client(for credentials: Credentials) -> Client? {
|
||||||
|
|
|
@ -59,14 +59,11 @@ struct SettingsScreen: View {
|
||||||
get: { client.credentials.isActive },
|
get: { client.credentials.isActive },
|
||||||
set: { new in
|
set: { new in
|
||||||
Task {
|
Task {
|
||||||
try? await client.credentials.setActive(flag: new)
|
await client.updActivity(new)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
)
|
)
|
||||||
.onTapGesture {
|
|
||||||
print("Tapped account \(client.credentials.bareJid)")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if parent == .main {
|
if parent == .main {
|
||||||
|
|
Loading…
Reference in a new issue