diff --git a/src/HabitTracker.ts b/src/HabitTracker.ts index 0329c5b..0851164 100644 --- a/src/HabitTracker.ts +++ b/src/HabitTracker.ts @@ -235,12 +235,14 @@ export default class HabitTracker { } this.app.fileManager.processFrontMatter(file, (frontmatter) => { - if(isTicked === 'true') { - frontmatter['entries'] = frontmatter['entries'].filter((e) => e !== date); + let entries = frontmatter["entries"] || []; + if (isTicked === "true") { + entries = entries.filter((e) => e !== date); } else { - frontmatter['entries'].push(date); - frontmatter['entries'].sort(); + entries.push(date); + entries.sort(); } + frontmatter["entries"] = entries; }); this.renderHabit(file.path, await this.getHabitEntries(file.path));