git » sdk » commit 000ab95

Expose reaction updates to C/swift

author Stephen Paul Weber
2025-04-14 18:08:25 UTC
committer Stephen Paul Weber
2025-04-14 18:08:25 UTC
parent 263a150501accfee4a8e518f36ba7048c7ae61c5

Expose reaction updates to C/swift

snikket/Reaction.hx +19 -3

diff --git a/snikket/Reaction.hx b/snikket/Reaction.hx
index 2fab0be..e957417 100644
--- a/snikket/Reaction.hx
+++ b/snikket/Reaction.hx
@@ -2,8 +2,16 @@ package snikket;
 
 using StringTools;
 
+#if cpp
+import HaxeCBridge;
+#end
+
 @:nullSafety(Strict)
 @:expose
+#if cpp
+@:build(HaxeCBridge.expose())
+@:build(HaxeSwiftBridge.expose())
+#end
 class Reaction {
 	public final senderId: String;
 	public final timestamp: String;
@@ -11,7 +19,8 @@ class Reaction {
 	public final key: String;
 	public final envelopeId: Null<String>;
 
-	public function new(senderId: String, timestamp: String, text: String, envelopeId: Null<String> = null, key: Null<String> = null) {
+	@:allow(snikket)
+	private function new(senderId: String, timestamp: String, text: String, envelopeId: Null<String> = null, key: Null<String> = null) {
 		this.senderId = senderId;
 		this.timestamp = timestamp;
 		this.text = text.replace("\u{fe0f}", "");
@@ -19,20 +28,27 @@ class Reaction {
 		this.key = key ?? this.text;
 	}
 
-	public function render<T>(forText: (String) -> T, forImage: (String, String) -> T) {
+	@:allow(snikket)
+	private function render<T>(forText: (String) -> T, forImage: (String, String) -> T) {
 		return forText(text + "\u{fe0f}");
 	}
 }
 
 @:expose
+#if cpp
+@:build(HaxeCBridge.expose())
+@:build(HaxeSwiftBridge.expose())
+#end
 class CustomEmojiReaction extends Reaction {
 	public final uri: String;
 
-	public function new(senderId: String, timestamp: String, text: String, uri: String, envelopeId: Null<String> = null) {
+	@:allow(snikket)
+	private function new(senderId: String, timestamp: String, text: String, uri: String, envelopeId: Null<String> = null) {
 		super(senderId, timestamp, text, envelopeId, uri);
 		this.uri = uri;
 	}
 
+	@:allow(snikket)
 	override public function render<T>(forText: (String) -> T, forImage: (String, String) -> T) {
 		final hash = Hash.fromUri(uri);
 		return forImage(text, hash?.toUri() ?? uri);