Skip to content

Commit 40070fd

Browse files
committed
fix
1 parent bc8b8a8 commit 40070fd

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

apps/obsidian/src/components/RelationshipSection.tsx

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ export const RelationshipSection = ({
8282
if (!relationType) return;
8383

8484
try {
85-
const activeFileContent = await plugin.app.vault.read(activeFile);
86-
const selectedNodeContent = await plugin.app.vault.read(selectedNode);
87-
8885
const appendLinkToFrontmatter = async (file: TFile, link: string) => {
8986
await plugin.app.fileManager.processFrontMatter(file, (fm) => {
9087
const existingLinks = Array.isArray(fm[relationType.id])
@@ -94,15 +91,14 @@ export const RelationshipSection = ({
9491
});
9592
};
9693

97-
try {
98-
await appendLinkToFrontmatter(activeFile, `[[${selectedNode.name}]]`);
99-
await appendLinkToFrontmatter(selectedNode, `[[${activeFile.name}]]`);
100-
} catch (innerError) {
101-
// Rollback changes if necessary
102-
await plugin.app.vault.modify(activeFile, activeFileContent);
103-
await plugin.app.vault.modify(selectedNode, selectedNodeContent);
104-
throw innerError;
105-
}
94+
await appendLinkToFrontmatter(
95+
activeFile,
96+
`"[[${selectedNode.name}]]"`.replace(/^['"]+|['"]+$/g, ""),
97+
);
98+
await appendLinkToFrontmatter(
99+
selectedNode,
100+
`"[[${activeFile.name}]]"`.replace(/^['"]+|['"]+$/g, ""),
101+
);
106102

107103
new Notice(
108104
`Successfully added ${relationType.label} with ${selectedNode.name}`,

0 commit comments

Comments
 (0)