Skip to content

Commit

Permalink
do not rollover duplicate notes fixes #130
Browse files Browse the repository at this point in the history
  • Loading branch information
lzilioli committed Mar 21, 2024
1 parent f45bba6 commit 0373234
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default class RolloverTodosPlugin extends Plugin {
// only relevant if !deleteOnComplete
cancelOnComplete: false,
removeEmptyTodos: false,
skipExistingTodos: false,
rolloverChildren: false,
rolloverOnFileCreate: true,
};
Expand Down Expand Up @@ -197,7 +198,7 @@ export default class RolloverTodosPlugin extends Plugin {
10000
);
} else {
const { templateHeading, deleteOnComplete, cancelOnComplete, removeEmptyTodos } =
const { templateHeading, deleteOnComplete, cancelOnComplete, removeEmptyTodos, skipExistingTodos } =
this.settings;

// check if there is a daily note from yesterday
Expand Down Expand Up @@ -258,6 +259,14 @@ export default class RolloverTodosPlugin extends Plugin {
file: file,
oldContent: `${dailyNoteContent}`,
};
// find todos that already exist in todays note
// and do not add them to today
if (skipExistingTodos) {
let existing_todos = await this.getAllUnfinishedTodos(file);
console.log(`rollover-daily-todos: filtering ${todos_today.length} tasks for tasks that already exist`);
todos_today = todos_today.filter(todo => !existing_todos.includes(todo));
console.log(`rollover-daily-todos: new count: ${todos_today.length}`);
}
const todos_todayString = `\n${todos_today.join("\n")}`;

// If template heading is selected, try to rollover to template heading
Expand Down
14 changes: 14 additions & 0 deletions src/ui/RolloverSettingTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,20 @@ export default class RolloverSettingTab extends PluginSettingTab {
})
);

new Setting(this.containerEl)
.setName("Skip existing todos in rollover")
.setDesc(
`If a todo from yesterday already exists in todays note, do not roll it over.`
)
.addToggle((toggle) =>
toggle
.setValue(this.plugin.settings.skipExistingTodos || false)
.onChange((value) => {
this.plugin.settings.skipExistingTodos = value;
this.plugin.saveSettings();
})
);

new Setting(this.containerEl)
.setName("Roll over children of todos")
.setDesc(
Expand Down

0 comments on commit 0373234

Please sign in to comment.