git » sdk » commit 407d7e6

If we have not display name, list participants

author Stephen Paul Weber
2025-03-26 19:13:34 UTC
committer Stephen Paul Weber
2025-03-26 19:13:34 UTC
parent 50e4aa1672859d22749ff4a601178030c03fe4e7

If we have not display name, list participants

Unless it's just us and one other or it's really big

snikket/Chat.hx +10 -1

diff --git a/snikket/Chat.hx b/snikket/Chat.hx
index 6110091..bab0897 100644
--- a/snikket/Chat.hx
+++ b/snikket/Chat.hx
@@ -465,7 +465,16 @@ abstract class Chat {
 		The display name of this Chat
 	**/
 	public function getDisplayName() {
-		return this.displayName == chatId && chatId == client.accountId() ? client.displayName() : this.displayName;
+		final fn = this.displayName == chatId && chatId == client.accountId() ? client.displayName() : this.displayName;
+		final participants = getParticipants();
+		if (fn == chatId && participants.length > 2 && participants.length < 20) {
+			return participants.map(id -> {
+				final p = getParticipantDetails(id);
+				p.isSelf ? null : p.displayName;
+			}).filter(fn -> fn != null).join(", ");
+		} else {
+			return fn;
+		}
 	}
 
 	@:allow(snikket)