mirror of
https://github.com/cdloh/obsidian-cron.git
synced 2026-07-22 07:40:30 +00:00
Add ability to do a run on Obsidian startup
This commit is contained in:
parent
62e2ef6b7c
commit
32ecb73efc
2 changed files with 19 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ import SyncChecker from './syncChecker';
|
|||
|
||||
export interface CronSettings {
|
||||
cronInterval: number;
|
||||
runOnStartup: boolean
|
||||
watchObsidianSync: boolean
|
||||
crons: Array<CRONJob>,
|
||||
locks: { [key: string]: CronLock }
|
||||
|
|
@ -22,6 +23,7 @@ export interface CRONJob {
|
|||
|
||||
const DEFAULT_SETTINGS: CronSettings = {
|
||||
cronInterval: 15,
|
||||
runOnStartup: true,
|
||||
watchObsidianSync: true,
|
||||
crons: [],
|
||||
locks: {}
|
||||
|
|
@ -48,6 +50,12 @@ export default class Cron extends Plugin {
|
|||
// load our cronjobs
|
||||
this.loadCrons()
|
||||
this.loadInterval()
|
||||
|
||||
this.app.workspace.onLayoutReady(() => {
|
||||
if(this.settings.runOnStartup) {
|
||||
this.runCron()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
public async runCron() {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,17 @@ export default class CronSettingTab extends PluginSettingTab {
|
|||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Run cron on startup')
|
||||
.setDesc('Do a cron run on startup instead of waiting for the first interval to pass')
|
||||
.addToggle(toggle => toggle
|
||||
.setValue(this.plugin.settings.runOnStartup)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.runOnStartup = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Enable Obsidian Sync Checker')
|
||||
.setDesc('Whether or not to wait for Obsidian sync before running any CRONs globally.')
|
||||
|
|
|
|||
Loading…
Reference in a new issue