git » sdk » commit a7c7103

Channel complettion sets sortId

author Stephen Paul Weber
2026-11-10 03:37:08 UTC
committer Stephen Paul Weber
2026-11-10 03:37:08 UTC
parent d82c204fdbeff2a1fdccc4900c5199823c8c6e35

Channel complettion sets sortId

borogove/Chat.hx +1 -0
test/TestChat.hx +33 -0

diff --git a/borogove/Chat.hx b/borogove/Chat.hx
index 7d439b6..ceafe96 100644
--- a/borogove/Chat.hx
+++ b/borogove/Chat.hx
@@ -1679,6 +1679,7 @@ class Channel extends Chat {
 			persistence.storeMembers(client.accountId(), chatId, [self]).then(_ -> trigger("members/update", [self]));
 			client.sortChats();
 			client.trigger("chats/update", [this]);
+			persistence.syncPoint(client.accountId(), chatId).then((point) -> doSync(point));
 		});
 	}
 
diff --git a/test/TestChat.hx b/test/TestChat.hx
index 24b84f7..100efe2 100644
--- a/test/TestChat.hx
+++ b/test/TestChat.hx
@@ -732,6 +732,39 @@ class TestChat extends utest.Test {
 		Assert.equals(Open, channel.uiState);
 	}
 
+	public function testCreationCompletionInitializesSortId(async: Async) {
+		final persistence = new Dummy();
+		final client = new Client("test@example.com", persistence);
+		final channel = new Channel(client, client.stream, persistence, "room@example.com", Creating);
+
+		client.stream.on("sendStanza", (stanza: Stanza) -> {
+			if (stanza.name != "iq") return EventUnhandled;
+
+			if (stanza.getChild("query", "http://jabber.org/protocol/disco#info") != null) {
+				client.stream.onStanza(
+					new Stanza("iq", { xmlns: "jabber:client", type: "result", id: stanza.attr.get("id"), from: "room@example.com", to: "test@example.com" })
+						.tag("query", { xmlns: "http://jabber.org/protocol/disco#info" })
+							.tag("identity", { category: "conference", type: "text" }).up()
+							.tag("feature", { "var": "http://jabber.org/protocol/muc" }).up()
+							.tag("feature", { "var": "urn:xmpp:mam:2" }).up()
+						.up()
+				);
+				return EventHandled;
+			}
+
+			if (stanza.findChild("{urn:xmpp:mam:2}query") != null) {
+				Assert.notNull(channel.sortId);
+				Assert.notNull(channel.sync);
+				async.done();
+				return EventHandled;
+			}
+
+			return EventUnhandled;
+		});
+
+		channel.completeCreation();
+	}
+
 	public function testSelfPingNoopWhileCreating() {
 		final persistence = new Dummy();
 		final client = new Client("test@example.com", persistence);