Skip to content

Commit

Permalink
Adds error notification, prevent unneeded changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan J.A. Murphy committed Feb 8, 2022
1 parent a835c79 commit 53f800d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/automators/onFileModifyAutomators/kanbanHelper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {CachedMetadata, LinkCache, TFile} from "obsidian";
import {CachedMetadata, LinkCache, Notice, TFile} from "obsidian";
import type MetaEdit from "../../main";
import type {KanbanProperty} from "../../Types/kanbanProperty";
import {abstractFileToMarkdownTFile} from "../../utility";
Expand Down Expand Up @@ -64,11 +64,16 @@ export class KanbanHelper extends OnFileModifyAutomator {
}
const targetProperty = fileProperties.find(prop => prop.key === board.property);
if (!targetProperty) {
log.logWarning(`'${board.property} not found in ${board.boardName}'`)
log.logWarning(`'${board.property} not found in ${board.boardName} for file "${linkFile.name}".'`);
new Notice(`'${board.property} not found in ${board.boardName} for file "${linkFile.name}".'`); // This notice will help users debug "Property not found in board" errors.
return;
}

await this.plugin.controller.updatePropertyInFile(targetProperty, heading, linkFile);
const propertyHasChanged = (targetProperty.content != heading); // Kanban Helper will check if the file's property is different from its current heading in the kanban and will only make changes to the file if there's a difference
if (propertyHasChanged) {
console.debug("Updating " + targetProperty.key + " of file " + linkFile.name + " to " + heading);
await this.plugin.controller.updatePropertyInFile(targetProperty, heading, linkFile);
}
}

private getTaskHeading(targetTaskContent: string, fileContent: string): string | null {
Expand Down

0 comments on commit 53f800d

Please sign in to comment.