Skip to content

Commit

Permalink
fix: memos client is not found any memos #21
Browse files Browse the repository at this point in the history
Signed-off-by: EINDEX <[email protected]>
  • Loading branch information
EINDEX committed Aug 25, 2023
1 parent f52702f commit a9ca219
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/memos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -220,6 +226,9 @@ class MemosSync {
}

private memosFitler(memos: Array<Memo>): Array<Memo> {
if (!memos) {
return []
}
return memos.filter((memo) => {
if (this.tagFilterList!.length === 0) {
return true;
Expand Down

0 comments on commit a9ca219

Please sign in to comment.