From a9ca219412f449791b69b4058383ecc2ee4522ad Mon Sep 17 00:00:00 2001 From: EINDEX Date: Fri, 25 Aug 2023 16:46:45 +0800 Subject: [PATCH] fix: memos client is not found any memos #21 Signed-off-by: EINDEX --- src/memos.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/memos.ts b/src/memos.ts index 4f6986a..7443667 100644 --- a/src/memos.ts +++ b/src/memos.ts @@ -51,7 +51,7 @@ class MemosSync { await this.choosingClient(); if (this.memosClient === undefined || this.memosClient === null) { logseq.UI.showMsg("Memos Sync Setup issue", "error"); - return + return; } try { await this.sync(); @@ -84,16 +84,22 @@ class MemosSync { private async sync() { await this.beforeSync(); + if (this.memosClient === undefined || this.memosClient === null) { + await this.choosingClient(); + } + let maxMemoId = await this.lastSyncId(); let newMaxMemoId = maxMemoId; let end = false; let cousor = 0; + while (!end) { const memos = await this.memosClient!.getMemos( BATCH_SIZE, cousor, this.includeArchive! ); + for (const memo of this.memosFitler(memos)) { if (memo.id <= maxMemoId) { end = true; @@ -220,6 +226,9 @@ class MemosSync { } private memosFitler(memos: Array): Array { + if (!memos) { + return [] + } return memos.filter((memo) => { if (this.tagFilterList!.length === 0) { return true;