git » sdk » commit 5092345

After config form is submitted, creation is complete

author Stephen Paul Weber
2026-10-28 19:56:35 UTC
committer Stephen Paul Weber
2026-11-09 14:51:19 UTC
parent 73ee8b39c67b81fda8b8885cf471143dbb430c31

After config form is submitted, creation is complete

borogove/Chat.hx +15 -1
borogove/MucSettingsCommand.hx +12 -1

diff --git a/borogove/Chat.hx b/borogove/Chat.hx
index 6d169a0..0b58eb4 100644
--- a/borogove/Chat.hx
+++ b/borogove/Chat.hx
@@ -1657,6 +1657,19 @@ class Channel extends Chat {
 		}
 	}
 
+	@:allow(borogove)
+	private function completeCreation(): Void {
+		if (uiState != Creating) return;
+
+		uiState = Open;
+		outbox.start();
+		client.channelPinger.schedule(this);
+		persistence.storeChats(client.accountId(), [this]);
+		persistence.storeMembers(client.accountId(), chatId, [self]).then(_ -> trigger("members/update", [self]));
+		client.sortChats();
+		client.trigger("chats/update", [this]);
+	}
+
 	private function selfPingSuccess() {
 		if (nickInUse() != client.displayName()) {
 			final desiredFullJid = JID.parse(chatId).withResource(client.displayName());
@@ -1785,7 +1798,8 @@ class Channel extends Chat {
 	override public function commands(): Promise<Array<Command>> {
 		return super.commands().then((cmds: Array<Command>) -> {
 			if (isOwner()) {
-				cmds.push(new MucSettingsCommand(client, JID.parse(chatId)));
+				final onCompleted = uiState == Creating ? () -> completeCreation() : null;
+				cmds.push(new MucSettingsCommand(client, JID.parse(chatId), onCompleted));
 			}
 			return cmds;
 		});
diff --git a/borogove/MucSettingsCommand.hx b/borogove/MucSettingsCommand.hx
index 660bd98..94d17ba 100644
--- a/borogove/MucSettingsCommand.hx
+++ b/borogove/MucSettingsCommand.hx
@@ -12,9 +12,19 @@ import HaxeCBridge;
 #end
 
 class MucSettingsCommand extends Command {
+	private var onCompleted: Null<()->Void>;
+
 	@:allow(borogove)
-	public function new(client: Client, jid: JID) {
+	public function new(client: Client, jid: JID, ?onCompleted: ()->Void) {
 		super(client, { jid: jid, name: "Settings", node: "muc-settings" });
+		this.onCompleted = onCompleted;
+	}
+
+	@:allow(borogove.MucSettingsCommandSession)
+	private function notifyCompleted() {
+		final cb = onCompleted;
+		onCompleted = null;
+		if (cb != null) cb();
 	}
 
 	override public function execute(): Promise<CommandSession> {
@@ -82,6 +92,7 @@ class MucSettingsCommandSession extends CommandSession {
 					return;
 				}
 
+				Util.downcast(this.command, MucSettingsCommand)?.notifyCompleted();
 				resolve(new MucSettingsCommandSession("completed", null, [], [], this.command));
 			});
 			this.command.client.sendQuery(q);