Foam: Saving a file removes the graph edge in foam graph.

Created on 1 Dec 2020  Â·  5Comments  Â·  Source: foambubble/foam

  • Foam version: 0.7.2
  • Platform: Mac
  • Issue occur on the foam template repo: Yes | No

Summary
Saving a file removes incoming graph edges

Steps to reproduce

  1. create a new [[link]] in a file origin.md
  2. cmd-click to go to new file link.md
  3. save new file
    Result: the link between origin and link in the foam graph disappears.
bug

Most helpful comment

I can reproduce this too.

All 5 comments

I can reproduce this too.

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.

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...

  1. When you create the new [[link]] in origin.md, two things happen:

    • A node is created on the graph for link.md. Its links is empty as it has no outbound links.

    • The graph node for origin.md is recreated with links including link.md, thus the graph connections.

  2. When you edit and save link.md...

    • The 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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jetk picture jetk  Â·  6Comments

fmagin picture fmagin  Â·  7Comments

lsx7 picture lsx7  Â·  7Comments

clementoriol picture clementoriol  Â·  4Comments

coffenbacher picture coffenbacher  Â·  5Comments