fix
This commit is contained in:
parent
edf1b8782c
commit
40ebe72e1b
|
@ -77,6 +77,18 @@ extension Client {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func addRosterLocally(_ jid: String, name: String?, groups: [String]) async throws {
|
||||||
|
try await Roster.addRosterLocally(.init(
|
||||||
|
bareJid: credentials.bareJid,
|
||||||
|
contactBareJid: jid,
|
||||||
|
name: name,
|
||||||
|
subscription: "to",
|
||||||
|
ask: true,
|
||||||
|
data: .init(groups: groups, annotations: []),
|
||||||
|
locallyDeleted: false
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
func deleteRoster(_ roster: Roster) async throws {
|
func deleteRoster(_ roster: Roster) async throws {
|
||||||
_ = try await connection.module(.roster).removeItem(jid: JID(roster.contactBareJid))
|
_ = try await connection.module(.roster).removeItem(jid: JID(roster.contactBareJid))
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,4 +101,10 @@ extension Roster {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static func addRosterLocally(_ roster: Roster) async throws {
|
||||||
|
try await Database.shared.dbQueue.write { db in
|
||||||
|
try roster.save(db)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,6 +113,9 @@ extension ClientsStore {
|
||||||
throw AppError.clientNotFound
|
throw AppError.clientNotFound
|
||||||
}
|
}
|
||||||
try await addRoster(client.credentials, contactJID: chat.participant, name: nil, groups: [])
|
try await addRoster(client.credentials, contactJID: chat.participant, name: nil, groups: [])
|
||||||
|
// Hack here. Because we want to show chat immediately after adding roster (without waiting for server
|
||||||
|
// response and update rosters list) we need to write it to db manually
|
||||||
|
try await client.addRosterLocally(chat.participant, name: nil, groups: [])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue