Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add a setting to disable sync on start #198

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down Expand Up @@ -529,7 +529,6 @@ class OmnivoreSettingTab extends PluginSettingTab {
this.plugin.settings.customQuery = value
this.plugin.settings.syncAt = ''
await this.plugin.saveSettings()
this.display()
}),
)

Expand Down Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions src/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const DEFAULT_SETTINGS: OmnivoreSettings = {
intervalId: 0,
frontMatterVariables: [],
frontMatterTemplate: '',
syncOnStart: true,
}

export enum Filter {
Expand Down Expand Up @@ -78,4 +79,5 @@ export interface OmnivoreSettings {
frontMatterVariables: string[]
frontMatterTemplate: string
filenameDateFormat: string
syncOnStart: boolean
}
Loading