git » sdk » commit 05d490a

Fix first start race

author Stephen Paul Weber
2025-09-22 19:28:04 UTC
committer Stephen Paul Weber
2025-09-22 19:28:04 UTC
parent 67b59415569acff940ded597a8110ca647ba8af4

Fix first start race

The problem here is that we don't wait for this to be done before moving
on to other parts of the sync. So this may complete after the general
chats/update for all known chats has happened and even after the
joinAllChannels has happened. So make sure we update the UI and selfPing
in case we aren't joined.

snikket/Client.hx +3 -0

diff --git a/snikket/Client.hx b/snikket/Client.hx
index 4c3ff9c..fe02023 100644
--- a/snikket/Client.hx
+++ b/snikket/Client.hx
@@ -1408,10 +1408,13 @@ class Client extends EventEmitter {
 					handleChat(chat);
 					chats.unshift(chat);
 					persistence.storeChats(accountId(), [chat]);
+					this.trigger("chats/update", [chat]);
+					if (inSync && sendAvailable) chat.selfPing(false);
 				} else {
 					final chat = getDirectChat(jid, false);
 					handleChat(chat);
 					persistence.storeChats(accountId(), [chat]);
+					this.trigger("chats/update", [chat]);
 				}
 			}
 		});