git » sdk » commit f48a8b8

Do non-IDB work outside the IDB transaction

author Stephen Paul Weber
2026-09-09 15:04:57 UTC
committer Stephen Paul Weber
2026-09-09 15:04:57 UTC
parent 9b065626b0405bf7e7b2b024407d0eea9d3dd950

Do non-IDB work outside the IDB transaction

borogove/persistence/IDB.js +4 -1

diff --git a/borogove/persistence/IDB.js b/borogove/persistence/IDB.js
index a6feaba..4f9f424 100644
--- a/borogove/persistence/IDB.js
+++ b/borogove/persistence/IDB.js
@@ -1217,6 +1217,10 @@ export default async (dbname, media, tokenize, stemmer) => {
 		},
 
 		async storeMessages(account, messages) {
+			for (const m of messages.values()) {
+				await Promise.all(m.attachments.map((a) => a.lookup(this)));
+			}
+
 			const tx = db.transaction(["messages", "reactions"], "readwrite");
 			const store = tx.objectStore("messages");
 			const promises = [];
@@ -1358,7 +1362,6 @@ export default async (dbname, media, tokenize, stemmer) => {
 					} else {
 						store.put(toPut).onerror = console.error;
 					}
-					await Promise.all(message.attachments.map((a) => a.lookup(this)));
 					return message;
 				}