fix: syncing when not login

This commit is contained in:
xiangyu 2022-12-04 18:41:17 +08:00
parent d7f5fe94d2
commit 5eff599f3b
5 changed files with 13 additions and 1 deletions

View File

@ -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,
});

View File

@ -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;
}

View File

@ -98,6 +98,7 @@ class SyncUtils extends AddonBase {
path: "",
filename: "",
md5: "",
noteMd5: "",
lastsync: new Date().getTime(),
itemID: -1,
};

View File

@ -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;

1
typing/global.d.ts vendored
View File

@ -22,6 +22,7 @@ declare interface SyncStatus {
path: string;
filename: string;
md5: string;
noteMd5: string;
lastsync: number;
itemID: number;
}