git » sdk » commit 953ea89

Workaround for https://github.com/HaxeFoundation/haxe/issues/12914

author Stephen Paul Weber
2026-05-26 16:22:06 UTC
committer Stephen Paul Weber
2026-05-26 16:22:06 UTC
parent 73728abdeb8ee634b0486070593b9dbe893dde1a

Workaround for https://github.com/HaxeFoundation/haxe/issues/12914

borogove/ChatMessage.hx +1 -1
borogove/Reaction.hx +5 -0
test/TestSqlite.hx +9 -6

diff --git a/borogove/ChatMessage.hx b/borogove/ChatMessage.hx
index 3730064..f199f39 100644
--- a/borogove/ChatMessage.hx
+++ b/borogove/ChatMessage.hx
@@ -196,7 +196,7 @@ class ChatMessage {
 		Details of a set of reaction to this message
 	**/
 	public function reactionDetails(reactionKey: String): Array<Reaction> {
-		return reactions[reactionKey] ?? [];
+		return reactions[haxe.io.Bytes.ofString(reactionKey).toString()] ?? [];
 	}
 	#end
 
diff --git a/borogove/Reaction.hx b/borogove/Reaction.hx
index c03f20d..eefc972 100644
--- a/borogove/Reaction.hx
+++ b/borogove/Reaction.hx
@@ -37,7 +37,12 @@ class Reaction {
 		this.timestamp = timestamp;
 		this.text = text.replace("\u{fe0f}", "");
 		this.envelopeId = envelopeId;
+		#if cpp
+		// Workaround for has normalization issues
+		this.key = haxe.io.Bytes.ofString(key ?? this.text).toString();
+		#else
 		this.key = key ?? this.text;
+		#end
 	}
 
 	/**
diff --git a/test/TestSqlite.hx b/test/TestSqlite.hx
index 1a11e9a..9d374d7 100644
--- a/test/TestSqlite.hx
+++ b/test/TestSqlite.hx
@@ -577,7 +577,8 @@ class TestSqlite extends utest.Test {
 		});
 	}
 
-	/* segfault ? public function testStoreReaction(async: Async) {
+	@:timeout(1000)
+	public function testStoreReaction(async: Async) {
 		final account = "alice@example.com";
 		final builder = new ChatMessageBuilder();
 		builder.serverId = "srv1";
@@ -590,8 +591,10 @@ class TestSqlite extends utest.Test {
 		builder.recipients = [builder.to];
 		builder.replyTo = [builder.from];
 
+		// Workaround for https://github.com/HaxeFoundation/haxe/issues/12914
+		final key = haxe.io.Bytes.ofString("👍").toString();
 		persistence.storeMessages(account, [builder.build()]).then(_ -> {
-			final reaction = new Reaction("alice@example.com", "2020-01-01T00:00:01Z", "👍");
+			final reaction = new Reaction("alice@example.com", "2020-01-01T00:00:01Z", key);
 			final update = new ReactionUpdate(
 				"up1",
 				"srv1",
@@ -606,16 +609,16 @@ class TestSqlite extends utest.Test {
 			return persistence.storeReaction(account, update);
 		}).then(msg -> {
 			Assert.notNull(msg);
-			final reactions = msg.reactions;
+			final reactions: haxe.ds.StringMap<Array<Reaction>> = msg.reactions;
 			Assert.equals(1, Lambda.count({ iterator: () -> reactions.iterator() }));
-			Assert.isTrue(reactions.exists("👍"));
-			Assert.equals(1, reactions.get("👍").length);
+			Assert.isTrue(reactions.exists(key));
+			Assert.equals(1, reactions.get(key).length);
 			async.done();
 		}).catchError(e -> {
 			Assert.fail(Std.string(e));
 			async.done();
 		});
-	}*/
+	}
 
 	@:timeout(1000)
 	public function testUpdateMessageStatus(async: Async) {