From 5eff599f3bfe7a62d76839f4ffdaef7dfd2cd6a3 Mon Sep 17 00:00:00 2001 From: xiangyu <3170102889@zju.edu.cn> Date: Sun, 4 Dec 2022 18:41:17 +0800 Subject: [PATCH] fix: syncing when not login --- src/note/noteExportController.ts | 4 ++++ src/sync/syncController.ts | 6 ++++++ src/sync/syncUtils.ts | 1 + src/zotero/events.ts | 2 +- typing/global.d.ts | 1 + 5 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/note/noteExportController.ts b/src/note/noteExportController.ts index c781b16..269eb55 100644 --- a/src/note/noteExportController.ts +++ b/src/note/noteExportController.ts @@ -304,6 +304,10 @@ class NoteExport extends AddonBase { this._Addon.SyncUtils.getMDStatusFromContent(content).content, false ), + noteMd5: Zotero.Utilities.Internal.md5( + noteInfo.note.getNote(), + false + ), lastsync: new Date().getTime(), itemID: noteInfo.id, }); diff --git a/src/sync/syncController.ts b/src/sync/syncController.ts index 2d54619..23ed72d 100644 --- a/src/sync/syncController.ts +++ b/src/sync/syncController.ts @@ -84,11 +84,17 @@ class SyncController extends AddonBase { let MDAhead = false; let noteAhead = false; const md5 = Zotero.Utilities.Internal.md5(MDStatus.content, false); + const noteMd5 = Zotero.Utilities.Internal.md5(noteItem.getNote(), false); // MD5 doesn't match (md side change) if (md5 !== syncStatus.md5) { MDAhead = true; } + // MD5 doesn't match (note side change) + if (noteMd5 !== syncStatus.noteMd5) { + MDAhead = true; + } // Note version doesn't match (note side change) + // This might be unreliable when Zotero account is not login if (Number(MDStatus.meta.version) !== noteItem._version) { noteAhead = true; } diff --git a/src/sync/syncUtils.ts b/src/sync/syncUtils.ts index 5c4722f..eb67e7c 100644 --- a/src/sync/syncUtils.ts +++ b/src/sync/syncUtils.ts @@ -98,6 +98,7 @@ class SyncUtils extends AddonBase { path: "", filename: "", md5: "", + noteMd5: "", lastsync: new Date().getTime(), itemID: -1, }; diff --git a/src/zotero/events.ts b/src/zotero/events.ts index 9049a56..5857bd6 100644 --- a/src/zotero/events.ts +++ b/src/zotero/events.ts @@ -1123,7 +1123,7 @@ class ZoteroEvents extends AddonBase { (window as unknown as XUL.XULWindow).openDialog( "chrome://Knowledge4Zotero/content/export.xul", "", - "chrome,centerscreen,width=400,height=400,resizable=yes", + "chrome,centerscreen,width=400,height=500,resizable=yes", io ); await io.deferred.promise; diff --git a/typing/global.d.ts b/typing/global.d.ts index 064f6e9..3943e85 100644 --- a/typing/global.d.ts +++ b/typing/global.d.ts @@ -22,6 +22,7 @@ declare interface SyncStatus { path: string; filename: string; md5: string; + noteMd5: string; lastsync: number; itemID: number; }