diff --git a/Monal/another.im/XMPP/Models/Contact.swift b/Monal/another.im/XMPP/Models/Contact.swift index 37fdf17..51f1f63 100644 --- a/Monal/another.im/XMPP/Models/Contact.swift +++ b/Monal/another.im/XMPP/Models/Contact.swift @@ -9,7 +9,11 @@ struct Contact: Identifiable { var id: String { contactJid } var name: String { - nickname ?? contactJid + if let nickname { + nickname.isEmpty ? contactJid : nickname + } else { + contactJid + } } init?(_ obj: MLContact) { diff --git a/Monal/another.im/XMPP/MonalXmppWrapper.swift b/Monal/another.im/XMPP/MonalXmppWrapper.swift index b897459..8e8175c 100644 --- a/Monal/another.im/XMPP/MonalXmppWrapper.swift +++ b/Monal/another.im/XMPP/MonalXmppWrapper.swift @@ -27,6 +27,7 @@ final class MonalXmppWrapper: ObservableObject { // subscribe to monalxmpp notifications and fire notification for update subscribeToUpdates() + xmpp.reconnectAll() NotificationCenter.default.post(name: Notification.Name(kMonalRefresh), object: nil) // reconnect @@ -191,7 +192,7 @@ final class MonalChatWrapper: ObservableObject { } var chatTitle: String { - contact.name ?? contact.contactJid + contact.name } func sendText(_ text: String) { @@ -221,13 +222,10 @@ final class MonalChatWrapper: ObservableObject { ?? db.lastStanzaId(forAccount: NSNumber(value: account.id)) 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 if !(msgs ?? []).isEmpty { self?.refreshMessages() - } else { - let test = 4 - print(test) } } } diff --git a/Monal/another.im/XMPP/Scenaries/ScenarioLogIn.swift b/Monal/another.im/XMPP/Scenaries/ScenarioLogIn.swift index 238e5b0..616cb21 100644 --- a/Monal/another.im/XMPP/Scenaries/ScenarioLogIn.swift +++ b/Monal/another.im/XMPP/Scenaries/ScenarioLogIn.swift @@ -10,25 +10,11 @@ final class ScenarioLogIn { // TODO: Добавить автовключение отключенных аккаунтов при попытке ввести тот же JID // Обработать кейс когда бесячий monalxmpp возвращает nil при попытке добавить тот же JID 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 self?.successObserver = NotificationCenter.default.addObserver(forName: Notification.Name("kMLResourceBoundNotice"), object: nil, queue: .main) { _ in - print("--- DEBUG: kMLResourceBoundNotice") continuation.resume(returning: true) } self?.failureObserver = NotificationCenter.default.addObserver(forName: Notification.Name("kXMPPError"), object: nil, queue: .main) { _ in - print("--- DEBUG: kXMPPError") continuation.resume(returning: false) } }