| author | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-03-16 15:08:12 UTC |
| committer | Stephen Paul Weber
<singpolyma@singpolyma.net> 2026-03-16 15:08:12 UTC |
| parent | c9f8234d46d1a1ad36356314351486e537313c8e |
| borogove/persistence/IDB.js | +4 | -4 |
| borogove/persistence/Sqlite.hx | +1 | -1 |
diff --git a/borogove/persistence/IDB.js b/borogove/persistence/IDB.js index 5638afd..fd88c1e 100644 --- a/borogove/persistence/IDB.js +++ b/borogove/persistence/IDB.js @@ -254,24 +254,24 @@ export default async (dbname, media, tokenize, stemmer) => { } const obj = { - lastId: async function(account, jid) { + lastId: async function(account, chatId) { const tx = db.transaction(["messages"], "readonly"); const store = tx.objectStore("messages"); var cursor = null; - if (jid === null) { + if (chatId === null) { cursor = store.index("accounts").openCursor( IDBKeyRange.bound([account], [account, []]), "prev" ); } else { cursor = store.index("chats").openCursor( - IDBKeyRange.bound([account, jid], [account, jid, []]), + IDBKeyRange.bound([account, chatId], [account, chatId, []]), "prev" ); } while (true) { const result = await promisifyRequest(cursor); - if (!result || (result.value.syncPoint && result.value.serverId && (jid || result.value.serverIdBy === account))) { + if (!result || (result.value.syncPoint && result.value.serverId && ((chatId && result.value.serverIdBy == chatId) || result.value.serverIdBy === account))) { return result ? result.value.serverId : null; } else { result.continue(); diff --git a/borogove/persistence/Sqlite.hx b/borogove/persistence/Sqlite.hx index a77c5e5..f5189da 100644 --- a/borogove/persistence/Sqlite.hx +++ b/borogove/persistence/Sqlite.hx @@ -234,7 +234,7 @@ class Sqlite implements Persistence implements KeyValueStore { q += " AND mam_by=?"; params.push(accountId); } else { - q += " AND chat_id=?"; + q += " AND mam_by=?"; params.push(chatId); } if (chatId != null) {