mirror of
https://github.com/cdloh/obsidian-cron.git
synced 2026-07-22 07:40:30 +00:00
feat: Add option to disable on Mobile
This commit is contained in:
parent
ad8c0c0180
commit
996c4fdddb
2 changed files with 15 additions and 0 deletions
|
|
@ -9,6 +9,7 @@ import CronAPI from './api';
|
|||
export interface CronSettings {
|
||||
cronInterval: number;
|
||||
runOnStartup: boolean
|
||||
enableMobile: boolean
|
||||
watchObsidianSync: boolean
|
||||
crons: Array<CRONJob>,
|
||||
locks: { [key: string]: CronLock }
|
||||
|
|
@ -25,6 +26,7 @@ export interface CRONJob {
|
|||
const DEFAULT_SETTINGS: CronSettings = {
|
||||
cronInterval: 15,
|
||||
runOnStartup: true,
|
||||
enableMobile: true,
|
||||
watchObsidianSync: true,
|
||||
crons: [],
|
||||
locks: {}
|
||||
|
|
@ -55,6 +57,7 @@ export default class Cron extends Plugin {
|
|||
this.api = CronAPI.get(this)
|
||||
this.app.workspace.onLayoutReady(() => {
|
||||
if(this.settings.runOnStartup) {
|
||||
if(this.app.isMobile && !this.settings.enableMobile) { return }
|
||||
this.runCron()
|
||||
}
|
||||
})
|
||||
|
|
@ -120,6 +123,7 @@ export default class Cron extends Plugin {
|
|||
|
||||
public loadInterval() {
|
||||
clearInterval(this.interval)
|
||||
if(this.app.isMobile && !this.settings.enableMobile) { return }
|
||||
this.interval = window.setInterval(async () => { await this.runCron() }, this.settings.cronInterval * 60 * 1000)
|
||||
this.registerInterval(this.interval)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,17 @@ export default class CronSettingTab extends PluginSettingTab {
|
|||
})
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Enable Obsidian on Mobile')
|
||||
.setDesc('Whether or not to load jobs at all on Mobile devices. If disabled even jobs with mobile enabled will not run.')
|
||||
.addToggle(toggle => toggle
|
||||
.setValue(this.plugin.settings.enableMobile)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.enableMobile = value;
|
||||
await this.plugin.saveSettings();
|
||||
})
|
||||
);
|
||||
|
||||
const desc = document.createDocumentFragment();
|
||||
desc.append(
|
||||
"List of CRON Jobs to run. Jobs will not be ran until all 3 fields have been filled",
|
||||
|
|
|
|||
Loading…
Reference in a new issue