Skip to content

Commit

Permalink
fix for empty files; ugh
Browse files Browse the repository at this point in the history
  • Loading branch information
zoreet committed Dec 20, 2023
1 parent 2d8b4f4 commit 2a811b3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/HabitTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 2a811b3

Please sign in to comment.