git » sdk » commit 3cd91ac

Fix reaction load

author Stephen Paul Weber
2025-05-12 13:19:45 UTC
committer Stephen Paul Weber
2025-05-12 13:36:16 UTC
parent 59344f30af8d27a164bae766e2d92d3aadb48b67

Fix reaction load

snikket/persistence/Sqlite.hx +6 -2

diff --git a/snikket/persistence/Sqlite.hx b/snikket/persistence/Sqlite.hx
index fc6d1ce..8f7bdb2 100644
--- a/snikket/persistence/Sqlite.hx
+++ b/snikket/persistence/Sqlite.hx
@@ -689,7 +689,10 @@ class Sqlite implements Persistence implements KeyValueStore {
 	private function hydrateReactions(accountId: String, messages: Array<ChatMessage>) {
 		return fetchReactions(accountId, messages.map(m -> ({ chatId: m.chatId(), serverId: m.serverId, serverIdBy: m.serverIdBy, localId: m.localId }))).then(result -> {
 			for (id => reactions in result) {
-				final m = messages.find(m -> ((m.serverId == null ? m.localId : m.serverId + "\n" + m.serverIdBy) + "\n" + m.chatId()) == id);
+				final m = messages.find(m ->
+					((m.serverId == null ? m.localId : m.serverId + "\n" + m.serverIdBy) + "\n" + m.chatId()) == id ||
+					((m.localId == null ? m.serverId + "\n" + m.serverIdBy : m.localId) + "\n" + m.chatId()) == id
+				);
 				if (m != null) m.set_reactions(reactions);
 			}
 			return messages;
@@ -705,7 +708,8 @@ class Sqlite implements Persistence implements KeyValueStore {
 				q.add(" OR (mam_id=? AND mam_by=?)");
 				params.push(item.serverId);
 				params.push(item.serverIdBy);
-			} else {
+			}
+			if (item.localId != null) {
 				q.add(" OR stanza_id=?");
 				params.push(item.localId);
 			}