File tree Expand file tree Collapse file tree 1 file changed +8
-12
lines changed
apps/obsidian/src/components Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Original file line number Diff line number Diff 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 } ` ,
You can’t perform that action at this time.
0 commit comments