git » sdk » commit 9a2952e

Notify message before chat update

author Stephen Paul Weber
2024-11-12 21:44:26 UTC
committer Stephen Paul Weber
2024-11-12 21:44:26 UTC
parent 8c66813209fb68789e55b5a1de4ebbdfc209b99c

Notify message before chat update

To get rid of a data problem if the frontend updates unread count based
on the chat update, then increments based on the new message.

snikket/Client.hx +1 -1

diff --git a/snikket/Client.hx b/snikket/Client.hx
index e5c5beb..52360bd 100644
--- a/snikket/Client.hx
+++ b/snikket/Client.hx
@@ -155,12 +155,12 @@ class Client extends EventEmitter {
 					if (chat == null && stanza.attr.get("type") != "groupchat") chat = getDirectChat(chatMessage.chatId());
 					if (chat != null) {
 						final updateChat = (chatMessage) -> {
+							notifyMessageHandlers(chatMessage);
 							if (chatMessage.versions.length < 1 || chat.lastMessageId() == chatMessage.serverId || chat.lastMessageId() == chatMessage.localId) {
 								chat.setLastMessage(chatMessage);
 								if (chatMessage.versions.length < 1) chat.setUnreadCount(chatMessage.isIncoming() ? chat.unreadCount() + 1 : 0);
 								chatActivity(chat);
 							}
-							notifyMessageHandlers(chatMessage);
 						};
 						chatMessage = chat.prepareIncomingMessage(chatMessage, stanza);
 						if (chatMessage.serverId == null) {