This commit is contained in:
Woit 2024-11-30 00:06:11 +01:00
parent 880408b04a
commit f8ce451b63
3 changed files with 8 additions and 20 deletions

View file

@ -9,7 +9,11 @@ struct Contact: Identifiable {
var id: String { contactJid } var id: String { contactJid }
var name: String { var name: String {
nickname ?? contactJid if let nickname {
nickname.isEmpty ? contactJid : nickname
} else {
contactJid
}
} }
init?(_ obj: MLContact) { init?(_ obj: MLContact) {

View file

@ -27,6 +27,7 @@ final class MonalXmppWrapper: ObservableObject {
// subscribe to monalxmpp notifications and fire notification for update // subscribe to monalxmpp notifications and fire notification for update
subscribeToUpdates() subscribeToUpdates()
xmpp.reconnectAll()
NotificationCenter.default.post(name: Notification.Name(kMonalRefresh), object: nil) NotificationCenter.default.post(name: Notification.Name(kMonalRefresh), object: nil)
// reconnect // reconnect
@ -191,7 +192,7 @@ final class MonalChatWrapper: ObservableObject {
} }
var chatTitle: String { var chatTitle: String {
contact.name ?? contact.contactJid contact.name
} }
func sendText(_ text: String) { func sendText(_ text: String) {
@ -221,13 +222,10 @@ final class MonalChatWrapper: ObservableObject {
?? db.lastStanzaId(forAccount: NSNumber(value: account.id)) ?? db.lastStanzaId(forAccount: NSNumber(value: account.id))
acc.setMAMQueryMostRecentFor(monalContact, before: lastStanzaId) { [weak self] msgs, _ in acc.setMAMQueryMostRecentFor(monalContact, before: lastStanzaId) { [weak self] msgs, _ in
DispatchQueue.main.async { [weak self] in DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in
self?.mamRequestInProgress = false self?.mamRequestInProgress = false
if !(msgs ?? []).isEmpty { if !(msgs ?? []).isEmpty {
self?.refreshMessages() self?.refreshMessages()
} else {
let test = 4
print(test)
} }
} }
} }

View file

@ -10,25 +10,11 @@ final class ScenarioLogIn {
// TODO: Добавить автовключение отключенных аккаунтов при попытке ввести тот же JID // TODO: Добавить автовключение отключенных аккаунтов при попытке ввести тот же JID
// Обработать кейс когда бесячий monalxmpp возвращает nil при попытке добавить тот же JID // Обработать кейс когда бесячий monalxmpp возвращает nil при попытке добавить тот же JID
func tryLogin(_ login: String, _ password: String) async -> Bool { func tryLogin(_ login: String, _ password: String) async -> Bool {
NotificationCenter.default.addObserver(forName: Notification.Name("kMonalUpdateBundleFetchStatus"), object: nil, queue: .main) { _ in
print("--- DEBUG: kMonalUpdateBundleFetchStatus")
}
NotificationCenter.default.addObserver(forName: Notification.Name("kMonalFinishedOmemoBundleFetch"), object: nil, queue: .main) { _ in
print("--- DEBUG: kMonalFinishedOmemoBundleFetch")
}
NotificationCenter.default.addObserver(forName: Notification.Name("kMonalFinishedCatchup"), object: nil, queue: .main) { _ in
print("--- DEBUG: kMonalFinishedCatchup")
}
async let notify = await withCheckedContinuation { [weak self] continuation in async let notify = await withCheckedContinuation { [weak self] continuation in
self?.successObserver = NotificationCenter.default.addObserver(forName: Notification.Name("kMLResourceBoundNotice"), object: nil, queue: .main) { _ in self?.successObserver = NotificationCenter.default.addObserver(forName: Notification.Name("kMLResourceBoundNotice"), object: nil, queue: .main) { _ in
print("--- DEBUG: kMLResourceBoundNotice")
continuation.resume(returning: true) continuation.resume(returning: true)
} }
self?.failureObserver = NotificationCenter.default.addObserver(forName: Notification.Name("kXMPPError"), object: nil, queue: .main) { _ in self?.failureObserver = NotificationCenter.default.addObserver(forName: Notification.Name("kXMPPError"), object: nil, queue: .main) { _ in
print("--- DEBUG: kXMPPError")
continuation.resume(returning: false) continuation.resume(returning: false)
} }
} }