borogove/sdk
created pr with
135.1
cmds
checkout latest patchset:
ssh pr.pico.sh print 135 | git am -3checkout any patchset in a patch request:
ssh pr.pico.sh print 135.[rev] | git am -3add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 135
Patchset
135.1
Don't create a channel if there is existing chat
Eric Roberts
2026-08-12T17:52:53ZBit of weirdness here, if getChat returns something that is not a channel, then currently we just leave it. Maybe we should revisit this in the future.
Semantic diff summary
0 added,
0 modified,
0 signature changed,
0 removed
across 0 analyzed files
(2 files skipped: unsupported file type)
+10
-4
borogove/Client.hx
#
| ... | ... | @@ -2061,10 +2061,16 @@ class Client extends EventEmitter { | |
| 2061 | 2061 | } else { | |
| 2062 | 2062 | final cachedCaps = capsRepo.add(resultCaps); | |
| 2063 | 2063 | if (cachedCaps.isChannel(jid)) { | |
| 2064 | - | final chat = new Channel(this, this.stream, this.persistence, jid, uiState, false, false, null, cachedCaps); | |
| 2065 | - | chat.setupNotifications(); | |
| 2066 | - | chats.unshift(chat); | |
| 2067 | - | if (inSync && sendAvailable) chat.selfPing(false); | |
| 2064 | + | final existing = getChat(jid); | |
| 2065 | + | final chat = if (existing == null) { | |
| 2066 | + | final channel = new Channel(this, this.stream, this.persistence, jid, uiState, false, false, null, cachedCaps); | |
| 2067 | + | channel.setupNotifications(); | |
| 2068 | + | if (inSync && sendAvailable) channel.selfPing(false); | |
| 2069 | + | chats.unshift(channel); | |
| 2070 | + | channel; | |
| 2071 | + | } else { | |
| 2072 | + | existing; | |
| 2073 | + | } | |
| 2068 | 2074 | handleChat(chat); | |
| 2069 | 2075 | persistence.storeChats(accountId(), [chat]); | |
| 2070 | 2076 | this.trigger("chats/update", [chat]); |
+26
-0
test/TestClient.hx
#
| ... | ... | @@ -761,6 +761,32 @@ class TestClient extends utest.Test { | |
| 761 | 761 | ); | |
| 762 | 762 | } | |
| 763 | 763 | ||
| 764 | + | public function testStartChatWith(async: Async) { | |
| 765 | + | final persistence = new Dummy(); | |
| 766 | + | final client = new Client("test@example.com", persistence); | |
| 767 | + | final chat = new borogove.Chat.Channel(client, client.stream, persistence, "room@example.com"); | |
| 768 | + | client.chats.push(chat); | |
| 769 | + | ||
| 770 | + | client.stream.on("sendStanza", (stanza: Stanza) -> { | |
| 771 | + | if (stanza.name == "iq" && stanza.attr.get("type") == "get") { | |
| 772 | + | final stanza = Stanza.parse('<iq from="room@example.com" type="result" id="${stanza.attr.get("id")}" xmlns="jabber:client"> | |
| 773 | + | <query xmlns="http://jabber.org/protocol/disco#info"> | |
| 774 | + | <identity category="conference" type="text" name="Cool chatroom" /> | |
| 775 | + | <feature var="http://jabber.org/protocol/muc" /> | |
| 776 | + | </query> | |
| 777 | + | </iq>'); | |
| 778 | + | ||
| 779 | + | client.stream.onStanza(stanza); | |
| 780 | + | } | |
| 781 | + | return EventHandled; | |
| 782 | + | }); | |
| 783 | + | ||
| 784 | + | client.startChatWith("room@example.com", _->Open, _->{ | |
| 785 | + | Assert.equals(1, client.chats.length); | |
| 786 | + | async.done(); | |
| 787 | + | }); | |
| 788 | + | } | |
| 789 | + | ||
| 764 | 790 | #if js | |
| 765 | 791 | public function testPreferOMEMO() { | |
| 766 | 792 | final persistence = new Dummy(); |