From 8cf0d4914a55b0021284d8e405d987909ad7ad75 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 9 Dec 2024 23:04:30 -0500 Subject: [PATCH] Use correct id for reply stubs If we use only replyId the persistence layer doesn't know (without more context we probably don't want it to need to dig around for) which kind of id this is. We have a decent idea when we're creating the stub so just do it there. --- snikket/Message.hx | 5 +++++ snikket/persistence/browser.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/snikket/Message.hx b/snikket/Message.hx index dc06ea4..4e24647 100644 --- a/snikket/Message.hx +++ b/snikket/Message.hx @@ -262,6 +262,11 @@ class Message { final replyToMessage = new ChatMessage(); replyToMessage.from = replyToJid == null ? null : JID.parse(replyToJid); replyToMessage.replyId = replyToID; + if (isGroupchat) { + replyToMessage.serverId = replyToID; + } else { + replyToMessage.localId = replyToID; + } msg.replyToMessage = replyToMessage; } } diff --git a/snikket/persistence/browser.js b/snikket/persistence/browser.js index fd8e641..ecef1b7 100644 --- a/snikket/persistence/browser.js +++ b/snikket/persistence/browser.js @@ -365,7 +365,7 @@ const browser = (dbname, tokenize, stemmer) => { if (message.serverId && !message.serverIdBy) throw "Cannot store a message with a server id and no by"; new Promise((resolve) => // Hydrate reply stubs - message.replyToMessage && !message.replyToMessage.serverIdBy ? this.getMessage(account, message.chatId(), message.replyToMessage.getReplyId(), message.replyToMessage.getReplyId(), resolve) : resolve(message.replyToMessage) + message.replyToMessage && !message.replyToMessage.serverIdBy ? this.getMessage(account, message.chatId(), message.replyToMessage.serverId, message.replyToMessage.localId, resolve) : resolve(message.replyToMessage) ).then((replyToMessage) => { message.replyToMessage = replyToMessage; const tx = db.transaction(["messages", "reactions"], "readwrite");