git » sdk » commit ced4c2b

Return true to stop searching

author Stephen Paul Weber
2025-10-22 19:18:15 UTC
committer Stephen Paul Weber
2025-10-22 19:18:15 UTC
parent 7384aeda6e3001646793e1633b9128472d2032ac

Return true to stop searching

borogove/Client.hx +3 -3

diff --git a/borogove/Client.hx b/borogove/Client.hx
index f9ead61..a89e078 100644
--- a/borogove/Client.hx
+++ b/borogove/Client.hx
@@ -876,7 +876,7 @@ class Client extends EventEmitter {
 		@param q the search query to use
 		@param callback takes two arguments, the query that was used and the array of results
 	**/
-	public function findAvailableChats(q:String, callback:(String, Array<AvailableChat>) -> Void) {
+	public function findAvailableChats(q:String, callback:(String, Array<AvailableChat>) -> Bool) {
 		var results = [];
 		final query = StringTools.trim(q);
 		final checkAndAdd = (jid: JID, prepend = false) -> {
@@ -896,7 +896,7 @@ class Client extends EventEmitter {
 					final note = jid.asString() + (identity == null ? "" : " (" + identity.type + ")");
 					add(new AvailableChat(jid.asString(), displayName, note, resultCaps));
 				}
-				callback(q, results);
+				if (callback != null && callback(q, results)) callback = null;
 			});
 			sendQuery(discoGet);
 		};
@@ -953,7 +953,7 @@ class Client extends EventEmitter {
 			}
 		}
 		if (!jid.isValid() && results.length > 0) {
-			callback(q, results);
+			if (callback != null && callback(q, results)) callback = null;
 		}
 	}