| author | Stephen Paul Weber
<singpolyma@singpolyma.net> 2023-11-29 20:22:06 UTC |
| committer | Stephen Paul Weber
<singpolyma@singpolyma.net> 2023-12-11 15:59:51 UTC |
| parent | dc0e56cc1924a8ba47a0bd618b0ec6e60ae2cdda |
| xmpp/Client.hx | +21 | -20 |
diff --git a/xmpp/Client.hx b/xmpp/Client.hx index 8ff6cfb..dde8942 100644 --- a/xmpp/Client.hx +++ b/xmpp/Client.hx @@ -388,28 +388,29 @@ class Client extends xmpp.EventEmitter { } public function start() { - persistence.getChats(accountId(), (protoChats) -> { - for (protoChat in protoChats) { - chats.push(protoChat.toChat(this, stream, persistence)); - } - persistence.getChatsUnreadDetails(accountId(), chats, (details) -> { - for (detail in details) { - var chat = getChat(detail.chatId); - if (chat != null) { - chat.setLastMessage(detail.message); - chat.setUnreadCount(detail.unreadCount); - } + persistence.getLogin(accountId(), (clientId, token, fastCount, displayName) -> { + persistence.getStreamManagement(accountId(), (smId, smOut, smIn, smOutQ) -> { + stream.clientId = clientId ?? ID.long(); + jid = jid.withResource(stream.clientId); + if (!setDisplayName(displayName) && clientId == null) { + persistence.storeLogin(jid.asBare().asString(), stream.clientId, this.displayName(), null); } - chats.sort((a, b) -> -Reflect.compare(a.lastMessageTimestamp() ?? "0", b.lastMessageTimestamp() ?? "0")); - this.trigger("chats/update", chats); - - persistence.getStreamManagement(accountId(), (smId, smOut, smIn, smOutQ) -> { - persistence.getLogin(accountId(), (clientId, token, fastCount, displayName) -> { - stream.clientId = clientId ?? ID.long(); - jid = jid.withResource(stream.clientId); - if (!setDisplayName(displayName) && clientId == null) { - persistence.storeLogin(jid.asBare().asString(), stream.clientId, this.displayName(), null); + + persistence.getChats(accountId(), (protoChats) -> { + for (protoChat in protoChats) { + chats.push(protoChat.toChat(this, stream, persistence)); + } + persistence.getChatsUnreadDetails(accountId(), chats, (details) -> { + for (detail in details) { + var chat = getChat(detail.chatId); + if (chat != null) { + chat.setLastMessage(detail.message); + chat.setUnreadCount(detail.unreadCount); + } } + chats.sort((a, b) -> -Reflect.compare(a.lastMessageTimestamp() ?? "0", b.lastMessageTimestamp() ?? "0")); + this.trigger("chats/update", chats); + stream.on("auth/password-needed", (data) -> { fastMechanism = data.mechanisms.find((mech) -> mech.canFast)?.name; if (token == null || fastMechanism == null) {