Skip to content

Commit a9ca219

Browse files
committed
fix: memos client is not found any memos #21
Signed-off-by: EINDEX <snowstarlbk@gmail.com>
1 parent f52702f commit a9ca219

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/memos.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class MemosSync {
5151
await this.choosingClient();
5252
if (this.memosClient === undefined || this.memosClient === null) {
5353
logseq.UI.showMsg("Memos Sync Setup issue", "error");
54-
return
54+
return;
5555
}
5656
try {
5757
await this.sync();
@@ -84,16 +84,22 @@ class MemosSync {
8484
private async sync() {
8585
await this.beforeSync();
8686

87+
if (this.memosClient === undefined || this.memosClient === null) {
88+
await this.choosingClient();
89+
}
90+
8791
let maxMemoId = await this.lastSyncId();
8892
let newMaxMemoId = maxMemoId;
8993
let end = false;
9094
let cousor = 0;
95+
9196
while (!end) {
9297
const memos = await this.memosClient!.getMemos(
9398
BATCH_SIZE,
9499
cousor,
95100
this.includeArchive!
96101
);
102+
97103
for (const memo of this.memosFitler(memos)) {
98104
if (memo.id <= maxMemoId) {
99105
end = true;
@@ -220,6 +226,9 @@ class MemosSync {
220226
}
221227

222228
private memosFitler(memos: Array<Memo>): Array<Memo> {
229+
if (!memos) {
230+
return []
231+
}
223232
return memos.filter((memo) => {
224233
if (this.tagFilterList!.length === 0) {
225234
return true;

0 commit comments

Comments
 (0)