0.7.2Summary
Saving a file removes incoming graph edges
Steps to reproduce
[[link]] in a file origin.mdlink.mdorigin and link in the foam graph disappears.I can reproduce this too.
Sharing some hopefully useful additional info:
[[link]] in origin.md - Don't saveorigin.md's link references get updated.link.md and save the file. The link disappears on the graph.origin.md again.The same happens when you _do_ save origin.md before clicking [[link]]. In both cases you need to re-save origin.md after saving link.md.
Third method: Hold ctrl/cmd and hover over [[link]] without clicking to generate the reference. _Then_ save. Issue still happens.
This mostly creates issues when you are several links deep. Saving 20 files
that didn't change is a hassle.
On Tue, Dec 1, 2020, 19:54 Andrew Natoli notifications@github.com wrote:
Sharing some hopefully useful additional info:
- Create a new [[link]] in origin.md - Don't save
- When you cmd+click the link, the new file is created and origin.md's
link references get updated.- The link appears on the graph.
- Go to the new link.md and save the file. The link disappears on the
graph.- The link returns when you save origin.md again.
The same happens when you do save origin.md before clicking [[link]].
In both cases you need to re-save origin.md after saving link.md.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/foambubble/foam/issues/393#issuecomment-736750035,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAUI5C2KEHM65OC3KYVI2KDSSU3WRANCNFSM4UI6QE2Q
.
I can reproduce this too
Trying to debug a bit.. it looks like this is what's going on in note-graph.ts:setNote...
[[link]] in origin.md, two things happen:link.md. Its links is empty as it has no outbound links.origin.md is recreated with links including link.md, thus the graph connections.link.md...link.md node is recreated. In the process its edges are cleared.Then in datavis.ts:generateGraphData(), origin.md does not have any outgoing links detected anymore.
Update: So if you go back to origin.md and save it, it's re-created with the notes. But it looks like whenever I go to link.md and edit it, it _always_ loses the connection afterward as its node gets rebuilt.
Another:
So if we delete the node for link.md on save (yay immutability) graphlib deletes the outbound reference from origin.md:
https://github.com/dagrejs/graphlib/blob/master/lib/graph.js#L456
Looks like the doDelete in setNote was added in 0.7.2 so maybe we can replace that with getNote to satisfy the event handlers for note updates / additions? I'm experimenting with that approach locally and so far it's looking like a decent solution.
Most helpful comment
I can reproduce this too.