From d9c5fb29dbb0f5f9faa29823736f8b08c99b85ef Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Tue, 20 Feb 2024 09:44:54 +0800 Subject: [PATCH] fix: add a setting to disable sync on start (#198) --- src/main.ts | 19 ++++++++++++++++--- src/settings/index.ts | 2 ++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index c3f1e38..4630854 100644 --- a/src/main.ts +++ b/src/main.ts @@ -103,8 +103,8 @@ export default class OmnivorePlugin extends Plugin { this.scheduleSync() - // sync when the app is loaded if frequency is greater than zero - if (this.settings.frequency > 0) { + // sync when the app is loaded if syncOnStart is true + if (this.settings.syncOnStart) { await this.fetchOmnivore() } } @@ -529,7 +529,6 @@ class OmnivoreSettingTab extends PluginSettingTab { this.plugin.settings.customQuery = value this.plugin.settings.syncAt = '' await this.plugin.saveSettings() - this.display() }), ) @@ -644,6 +643,20 @@ class OmnivoreSettingTab extends PluginSettingTab { }) }) + new Setting(containerEl) + .setName('Sync on Start') + .setDesc( + 'Check this box if you want to sync with Omnivore when the app is loaded', + ) + .addToggle((toggle) => + toggle + .setValue(this.plugin.settings.syncOnStart) + .onChange(async (value) => { + this.plugin.settings.syncOnStart = value + await this.plugin.saveSettings() + }), + ) + new Setting(containerEl) .setName('Frequency') .setDesc( diff --git a/src/settings/index.ts b/src/settings/index.ts index d72c167..2c4f63a 100644 --- a/src/settings/index.ts +++ b/src/settings/index.ts @@ -42,6 +42,7 @@ export const DEFAULT_SETTINGS: OmnivoreSettings = { intervalId: 0, frontMatterVariables: [], frontMatterTemplate: '', + syncOnStart: true, } export enum Filter { @@ -78,4 +79,5 @@ export interface OmnivoreSettings { frontMatterVariables: string[] frontMatterTemplate: string filenameDateFormat: string + syncOnStart: boolean }