git » sdk » commit c7ceb39

Store the "version" not the outer wrapper

author Stephen Paul Weber
2025-10-17 02:39:01 UTC
committer Stephen Paul Weber
2025-10-17 02:39:01 UTC
parent ec79596a9df94fc8c6a479e477eff896e12e5f5b

Store the "version" not the outer wrapper

In general for outgoing corrections these are the same except the inner
one has the localId of this specific version

borogove/persistence/IDB.js +1 -1

diff --git a/borogove/persistence/IDB.js b/borogove/persistence/IDB.js
index 1e1b625..8a3c802 100644
--- a/borogove/persistence/IDB.js
+++ b/borogove/persistence/IDB.js
@@ -195,7 +195,7 @@ export default async (dbname, media, tokenize, stemmer) => {
 
 	function correctMessage(account, message, result) {
 		// Newest (by timestamp) version wins for head
-		const newVersions = message.versions.length < 2 ? [message] : message.versions;
+		const newVersions = message.versions.length < 1 ? [message] : message.versions;
 		const storedVersions = result.value.versions || [];
 		// TODO: dedupe? There shouldn't be dupes...
 		const versions = (storedVersions.length < 1 ? [result.value] : storedVersions).concat(newVersions.filter(nv => !storedVersions.find(sv => nv.serverId === sv.serverId)).map((nv) => serializeMessage(account, nv))).sort((a, b) => b.timestamp.getTime() - a.timestamp.getTime());