| author | Stephen Paul Weber
<singpolyma@singpolyma.net> 2025-10-03 02:43:39 UTC |
| committer | Stephen Paul Weber
<singpolyma@singpolyma.net> 2025-10-03 02:43:39 UTC |
| parent | 518554831523f05305655a4268c0c6238d44986f |
| borogove/Client.hx | +8 | -2 |
| borogove/GenericStream.hx | +1 | -0 |
| borogove/streams/XmppJsStream.hx | +2 | -2 |
diff --git a/borogove/Client.hx b/borogove/Client.hx index ed32dca..7e0be40 100644 --- a/borogove/Client.hx +++ b/borogove/Client.hx @@ -139,9 +139,13 @@ class Client extends EventEmitter { return EventHandled; }); + this.on("chats/update", (data: Array<Chat>) -> { + stream.emitSMupdates = !Util.existsFast(chats, chat -> chat.uiState != Closed && chat.syncing()); + return EventHandled; + }); + stream.on("sm/update", (data) -> { - final anySyncHappening = Util.existsFast(chats, chat -> chat.uiState != Closed && chat.syncing()); - persistence.storeStreamManagement(accountId(), anySyncHappening ? null : data.sm); + persistence.storeStreamManagement(accountId(), stream.emitSMupdates ? data.sm : null); return EventHandled; }); @@ -616,6 +620,7 @@ class Client extends EventEmitter { Start this client running and trying to connect to the server **/ public function start() { + stream.emitSMupdates = false; // We don't care until after sync startOffline().then(_ -> persistence.getStreamManagement(accountId()) ).then((sm) -> { @@ -757,6 +762,7 @@ class Client extends EventEmitter { if (data.resumed) { inSync = true; + stream.emitSMupdates = true; this.trigger("status/online", {}); return EventHandled; } diff --git a/borogove/GenericStream.hx b/borogove/GenericStream.hx index 95f9793..f1bdd0a 100644 --- a/borogove/GenericStream.hx +++ b/borogove/GenericStream.hx @@ -13,6 +13,7 @@ enum IqResult { abstract class GenericStream extends EventEmitter { public var clientId: Null<String> = null; public var csi(default, null) = false; + public var emitSMupdates = true; public function new() { super(); diff --git a/borogove/streams/XmppJsStream.hx b/borogove/streams/XmppJsStream.hx index 5c9dbcc..361a777 100644 --- a/borogove/streams/XmppJsStream.hx +++ b/borogove/streams/XmppJsStream.hx @@ -261,8 +261,8 @@ class XmppJsStream extends GenericStream { }); xmpp.on("stanza", function (stanza) { - this.onStanza(convertToStanza(stanza)); triggerSMupdate(); + this.onStanza(convertToStanza(stanza)); }); xmpp.streamManagement.on("ack", (stanza) -> { @@ -357,7 +357,7 @@ class XmppJsStream extends GenericStream { } private function triggerSMupdate() { - if (client == null || !client.streamManagement.enabled) return; + if (client == null || !client.streamManagement.enabled || !emitSMupdates) return; this.trigger( "sm/update", {