From 03a4213596d95ca7b8634b92b2e125d9e67a42e2 Mon Sep 17 00:00:00 2001 From: Val Packett Date: Mon, 1 Aug 2022 21:41:27 +0300 Subject: [PATCH] Plugin: only overwrite with server change if local tiddler is older --- plugins/tiddlypwa/main.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/tiddlypwa/main.js b/plugins/tiddlypwa/main.js index 7dc9fb2..2b5b152 100644 --- a/plugins/tiddlypwa/main.js +++ b/plugins/tiddlypwa/main.js @@ -464,8 +464,12 @@ Formatted with `deno fmt`. }; this.logger.log('remote change', thash); if (changedKeys.has(thash)) { - this.logger.log('conflict', thash); - // TODO: pick newer between the two, save older under special name, present results + const ourtid = txn.objectStore('tiddlers').get(tid.thash); + this.logger.log('conflict:', thash, 'server:', tid.mtime, 'local:', ourtid.mtime); + if (ourtid.mtime > tid.mtime) { + continue; + } + // TODO: save the older tiddler under a special name and present conflict results } txn.objectStore('tiddlers').put(tid); if (deleted) {