diff --git a/src/processing/automaton.ts b/src/processing/automaton.ts index 066500d..2e2aa70 100644 --- a/src/processing/automaton.ts +++ b/src/processing/automaton.ts @@ -43,8 +43,8 @@ class Automaton { new GetTasks(app, plugin, processor), new RemoveTasks(app, plugin), new SyncLabels(app, plugin), - new UpdateTasks(app, plugin, processor), new CreateTasks(app, plugin, processor), + new UpdateTasks(app, plugin, processor), ]; this.status = AutomatonStatus.READY; diff --git a/src/processing/processor.ts b/src/processing/processor.ts index d697371..ca37aee 100644 --- a/src/processing/processor.ts +++ b/src/processing/processor.ts @@ -78,6 +78,7 @@ class Processor { if (file === null) { return; } + if (this.plugin.settings.debugging) console.log("Processor: Save to vault", task, newTask); await this.app.vault.process(file, data => { let content; if (this.plugin.settings.appendMode) { @@ -92,9 +93,9 @@ class Processor { } content = lines.join("\n"); } - this.plugin.cache.update(task); return content; }); + this.plugin.cache.update(task); } getTaskContent(task: PluginTask): string { diff --git a/src/vikunja/tasks.ts b/src/vikunja/tasks.ts index 2f81ad8..f454be8 100644 --- a/src/vikunja/tasks.ts +++ b/src/vikunja/tasks.ts @@ -38,33 +38,8 @@ class Tasks implements VikunjaAPI { } async getAllTasks(): Promise { - const gen = function* () { - let page = 0; - while (true) { - yield page++; - } - } - - const arrayRange = (start: number, stop: number, step: number) => - Array.from( - {length: (stop - start) / step + 1}, - (value, index) => start + index * step - ); - - const tasks: ModelsTask[] = []; - let lastResponse: ModelsTask[] = []; - const number_gen = gen(); - do { - const current_page = number_gen.next().value; - const page_array = arrayRange(current_page * 5, current_page * 5 + 4, 1); - if (this.plugin.settings.debugging) console.log("TasksApi: Getting tasks for page", current_page, page_array); - const response = await Promise.all(page_array.map(page => this.getTasksForPage(page))); - lastResponse = response.flat(); - if (this.plugin.settings.debugging) console.log("TasksApi: Got tasks from Vikunja", lastResponse); - tasks.push(...lastResponse); - } while (lastResponse.length > 0); - - return tasks; + const params: TasksAllGetRequest = {page: 0}; + return await this.tasksApi.tasksAllGet(params); } async getTasksForPage(page: number): Promise {