Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds error notification, prevent unneeded changes #60

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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