Skip to content

Commit

Permalink
add removeTask Option again
Browse files Browse the repository at this point in the history
  • Loading branch information
Heiss committed Aug 9, 2024
1 parent 6c97073 commit 08e7fd6
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
4 changes: 4 additions & 0 deletions src/processing/removeTasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class RemoveTasks implements IAutomatonSteps {
}

async step(localTasks: PluginTask[], vikunjaTasksBeforeDeletion: ModelsTask[]): Promise<StepsOutput> {
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};
Expand Down
25 changes: 21 additions & 4 deletions src/settings/mainSetting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface VikunjaPluginSettings {
backendToFindTasks: backendToFindTasks,
debugging: boolean,
removeLabelsIfInVaultNotUsed: boolean,
removeTasks: boolean,
removeTasksOnlyInDefaultProject: boolean,
enableCron: boolean,
cronInterval: number,
Expand Down Expand Up @@ -50,6 +51,7 @@ export const DEFAULT_SETTINGS: VikunjaPluginSettings = {
backendToFindTasks: backendToFindTasks.Dataview,
debugging: false,
removeLabelsIfInVaultNotUsed: false,
removeTasks: false,
removeTasksOnlyInDefaultProject: true,
enableCron: false,
cronInterval: 500,
Expand Down Expand Up @@ -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...")
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit 08e7fd6

Please sign in to comment.