diff --git a/manifest.json b/manifest.json index 46dd34c..488dc46 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "vikunja-sync", "name": "Vikunja Sync", - "version": "1.0.15", + "version": "1.0.16", "minAppVersion": "0.15.0", "description": "Integrates Vikunja.", "author": "Peter Heiss", diff --git a/package.json b/package.json index f869f47..72d2aa5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-vikunja-plugin", - "version": "1.0.15", + "version": "1.0.16", "description": "This is a sample plugin for Obsidian (https://obsidian.md)", "main": "main.js", "scripts": { diff --git a/src/processing/removeTasks.ts b/src/processing/removeTasks.ts index c8f2052..1cf9968 100644 --- a/src/processing/removeTasks.ts +++ b/src/processing/removeTasks.ts @@ -14,6 +14,10 @@ class RemoveTasks implements IAutomatonSteps { } async step(localTasks: PluginTask[], vikunjaTasksBeforeDeletion: ModelsTask[]): Promise { + if (!this.plugin.settings.removeTasks) { + return {localTasks, vikunjaTasks: vikunjaTasksBeforeDeletion}; + } + const vikunjaTasks = await this.removeTasksInVikunja(localTasks, vikunjaTasksBeforeDeletion); //const localTasks = await this.removeTasksInVault(localTasksBeforeDeletion, vikunjaTasksBeforeDeletion); return {localTasks, vikunjaTasks}; diff --git a/src/settings/mainSetting.ts b/src/settings/mainSetting.ts index 6e66e02..a46f0f0 100644 --- a/src/settings/mainSetting.ts +++ b/src/settings/mainSetting.ts @@ -20,6 +20,7 @@ export interface VikunjaPluginSettings { backendToFindTasks: backendToFindTasks, debugging: boolean, removeLabelsIfInVaultNotUsed: boolean, + removeTasks: boolean, removeTasksOnlyInDefaultProject: boolean, enableCron: boolean, cronInterval: number, @@ -50,6 +51,7 @@ export const DEFAULT_SETTINGS: VikunjaPluginSettings = { backendToFindTasks: backendToFindTasks.Dataview, debugging: false, removeLabelsIfInVaultNotUsed: false, + removeTasks: false, removeTasksOnlyInDefaultProject: true, enableCron: false, cronInterval: 500, @@ -544,16 +546,31 @@ export class MainSetting extends PluginSettingTab { })); new Setting(containerEl) - .setName("Remove tasks only in default project") - .setDesc("If enabled, only tasks in the default project will be removed when ID not found in Vault. Otherwise, all tasks will be removed nevertheless the configured project.") + .setName("Remove tasks if not found in vault") + .setDesc("If tasks not found in the vault, they will be deleted in Vikunja. Mostly, because you delete them. Very helpful, if you only create tasks through Obsidian.") .addToggle(toggle => toggle - .setValue(this.plugin.settings.removeTasksOnlyInDefaultProject) + .setValue(this.plugin.settings.removeTasks) .onChange(async (value: boolean) => { - this.plugin.settings.removeTasksOnlyInDefaultProject = value; + this.plugin.settings.removeTasks = value; await this.plugin.saveSettings(); + this.display(); })); + if (this.plugin.settings.removeTasks) { + + new Setting(containerEl) + .setName("Remove tasks only in default project") + .setDesc("If enabled, only tasks in the default project will be removed when ID not found in Vault. Otherwise, all tasks will be removed nevertheless the configured project.") + .addToggle(toggle => + toggle + .setValue(this.plugin.settings.removeTasksOnlyInDefaultProject) + .onChange(async (value: boolean) => { + this.plugin.settings.removeTasksOnlyInDefaultProject = value; + await this.plugin.saveSettings(); + })); + } + if (this.projects.length === 0) { new Setting(containerEl) .setName("Loading projects...") diff --git a/versions.json b/versions.json index 4541379..8aa0ad6 100644 --- a/versions.json +++ b/versions.json @@ -1,5 +1,6 @@ { "1.0.13": "0.15.0", "1.0.14": "0.15.0", - "1.0.15": "0.15.0" + "1.0.15": "0.15.0", + "1.0.16": "0.15.0" } \ No newline at end of file