From 096eea4440235516026ee77bfbc1852986362445 Mon Sep 17 00:00:00 2001 From: Joseph Mearman Date: Thu, 30 Mar 2023 07:33:54 +0100 Subject: [PATCH 1/4] add inferred types to loadArticles --- src/util.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/util.ts b/src/util.ts index 54f950a..2262a30 100644 --- a/src/util.ts +++ b/src/util.ts @@ -111,12 +111,12 @@ export const loadArticle = async ( export const loadArticles = async ( endpoint: string, apiKey: string, - after = 0, - first = 10, - updatedAt = "", - query = "", - includeContent = false, - format = "html" + after: number = 0, + first: number = 10, + updatedAt: string = "", + query: string = "", + includeContent: boolean = false, + format: string = "html" ): Promise<[Article[], boolean]> => { const res = await requestUrl({ url: endpoint, From 0c9add5c477ed087e9025c8a4805290e7feb545d Mon Sep 17 00:00:00 2001 From: Joseph Mearman Date: Thu, 30 Mar 2023 07:42:48 +0100 Subject: [PATCH 2/4] reset syncing state on first load plugin can get into bad state if obsidian is closed while syncing is in progress --- src/main.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index 3478284..e2aa0c8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -106,7 +106,7 @@ export default class OmnivorePlugin extends Plugin { async onload() { await this.loadSettings(); - + await this.resetSyncingSettingStateSetting(); this.addCommand({ id: "sync", name: "Sync", @@ -380,6 +380,11 @@ export default class OmnivorePlugin extends Plugin { return ""; } } + + private async resetSyncingSettingStateSetting() { + this.settings.syncing = false; + await this.saveSettings(); + } } class OmnivoreSettingTab extends PluginSettingTab { From bed72888efdf28b32f94448353caf4dc649a0152 Mon Sep 17 00:00:00 2001 From: Joseph Mearman Date: Thu, 30 Mar 2023 19:51:14 +0100 Subject: [PATCH 3/4] add message if sync is triggered again --- src/main.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index e2aa0c8..0ba68bb 100644 --- a/src/main.ts +++ b/src/main.ts @@ -178,7 +178,10 @@ export default class OmnivorePlugin extends Plugin { folder, } = this.settings; - if (syncing) return; + if (syncing) { + new Notice("🐢 Already syncing ..."); + return; + } if (!apiKey) { new Notice("Missing Omnivore api key"); From 8432a164cc6990f0613399e0cfee8489852dd7a2 Mon Sep 17 00:00:00 2001 From: Joseph Mearman Date: Thu, 30 Mar 2023 20:31:16 +0100 Subject: [PATCH 4/4] typo --- src/main.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.ts b/src/main.ts index 0ba68bb..93c077e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -106,7 +106,7 @@ export default class OmnivorePlugin extends Plugin { async onload() { await this.loadSettings(); - await this.resetSyncingSettingStateSetting(); + await this.resetSyncingStateSetting(); this.addCommand({ id: "sync", name: "Sync", @@ -384,7 +384,7 @@ export default class OmnivorePlugin extends Plugin { } } - private async resetSyncingSettingStateSetting() { + private async resetSyncingStateSetting() { this.settings.syncing = false; await this.saveSettings(); }