| author | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-03-16 13:48:16 UTC |
| committer | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-03-16 13:49:15 UTC |
| parent | 3b3e93d6eb3af5eed5803d1764042d2500af0026 |
| borogove/Chat.hx | +6 | -6 |
| borogove/persistence/IDB.js | +2 | -2 |
diff --git a/borogove/Chat.hx b/borogove/Chat.hx index 0944090..01dc203 100644 --- a/borogove/Chat.hx +++ b/borogove/Chat.hx @@ -502,8 +502,8 @@ abstract class Chat { /** An ID of the last message displayed to the user **/ - public function readUpTo() { - return readUpToId; + public function readUpTo(): Promise<Null<ChatMessage>> { + return persistence.getMessage(client.accountId(), chatId, readUpToId, null); } /** @@ -891,11 +891,11 @@ abstract class Chat { if (message.serverId == null || message.chatId() != chatId) return Promise.reject(null); if (readUpTo() == message.serverId) return Promise.reject(null); - if (readUpTo() == null) { + if (readUpToId == null) { return markReadUpToId(message.serverId, message.serverIdBy); } - return persistence.getMessage(client.accountId(), chatId, readUpTo(), null).then((readMessage) -> { + return readUpTo().then((readMessage) -> { if (readMessage != null && Reflect.compare(message.timestamp, readMessage.timestamp) <= 0) { return Promise.reject(null); } @@ -911,7 +911,7 @@ abstract class Chat { .tag("publish", { node: "urn:xmpp:mds:displayed:0" }) .tag("item", { id: chatId }) .tag("displayed", { xmlns: "urn:xmpp:mds:displayed:0"}) - .tag("stanza-id", { xmlns: "urn:xmpp:sid:0", id: readUpTo(), by: readUpToBy }) + .tag("stanza-id", { xmlns: "urn:xmpp:sid:0", id: readUpToId, by: readUpToBy }) .up().up().up(), new Stanza("x", { xmlns: "jabber:x:data", type: "submit" }) .tag("field", { "var": "FORM_TYPE", type: "hidden" }).textTag("value", "http://jabber.org/protocol/pubsub#publish-options").up() @@ -1510,7 +1510,7 @@ class Channel extends Chat { client.sortChats(); } - final readIndex = dedupedMessages.findLastIndex((m) -> m.serverId == readUpTo() || !m.isIncoming()); + final readIndex = dedupedMessages.findLastIndex((m) -> m.serverId == readUpToId || !m.isIncoming()); if (readIndex < 0) { setUnreadCount(unreadCount() + dedupedMessages.length); } else { diff --git a/borogove/persistence/IDB.js b/borogove/persistence/IDB.js index c48c1df..6c62f00 100644 --- a/borogove/persistence/IDB.js +++ b/borogove/persistence/IDB.js @@ -359,7 +359,7 @@ export default async (dbname, media, tokenize, stemmer) => { if (result[value.chatId]) { result[value.chatId] = result[value.chatId].then((details) => { if (!details.foundAll) { - const readUpTo = chats[value.chatId]?.readUpTo(); + const readUpTo = chats[value.chatId]?.readUpToId; if (readUpTo === value.serverId || readUpTo === value.localId || value.direction == enums.borogove_MessageDirection.MessageSent) { details.foundAll = true; } else { @@ -369,7 +369,7 @@ export default async (dbname, media, tokenize, stemmer) => { return details; }); } else { - const readUpTo = chats[value.chatId]?.readUpTo(); + const readUpTo = chats[value.chatId]?.readUpToId; const haveRead = readUpTo === value.serverId || readUpTo === value.localId || value.direction == enums.borogove_MessageDirection.MessageSent; result[value.chatId] = hydrateMessage(value).then((m) => ({ chatId: value.chatId, message: m, unreadCount: haveRead ? 0 : 1, foundAll: haveRead })); }