-
Notifications
You must be signed in to change notification settings - Fork 678
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
fix(dataviz): Don't delete node for note on update - #393 #394
fix(dataviz): Don't delete node for note on update - #393 #394
Conversation
hi @AndrewNatoli, thanks for looking into this and spotting the issue with the inbound links. |
Aha, I see that now. I'll try and get back to this a bit later today, thanks for confirming how that process works! |
How would you feel about lifting this:
out of In |
happy to go with that 👍 |
packages/foam-core/src/note-graph.ts
Outdated
@@ -91,9 +94,7 @@ export class NoteGraph implements NoteGraphAPI { | |||
const note = this.getNote(noteId); | |||
if (isSome(note)) { | |||
this.graph.removeNode(noteId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would cause the inbound/outbound links to be removed, no?
I reckon we would need to set it to null
to keep the existing inbound connections
(can you add a test case for that?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like doDelete
is now only being called when a note is deleted which I think means this shouldn't be a problem anymore.
If there's a concern about a deletion rippling to connections between neighboring files, those seem fine.
Here if I delete "types of food" the original connections in "soup" remain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if pasta
has a connection to types-of-food
, I would expect to see that connection even afterwards, but instead of being associated to a real note, it would be associated to a placeholder note
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see.
So... On delete, if a note has inbound links, do not entirely remove the node just set it back to a placeholder.
This seems to be an existing problem with the current release.
Mind if I add that to the issue tracker and try to address that separately? It doesn't look like it'll overlap with this change to update events.
I'm also having some recurring issues running the extension in dev mode that are making it a little tricky, I'll ask about those in Discord later and see if it's anything I can update the docs for as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that your specific issue was with the removal of the inbound links, which you have now solved.
I see this issue as fixing a problem with the delete function, which has not been solved yet.
Is there a reason why you'd rather not make the change here?
Also, it's important to add the test cases for:
- the bug that was fixed
- the current incorrect behavior (the fact that tests are not failing now means we are not capturing this case)
I am also happy to contribute to the branch, for me what matters is merging a complete fix to the deletion bug.
hi @AndrewNatoli, thanks again for taking the initiative to fix this bug. Let me know if my message on Discord helped you with the dev issues. The problem is caused by a mixture of commonjs and non-commonjs modules, so the fixes in Also, let me know if you are happy to implement the changes I have requested, or you'd rather me doing it - whether on this branch or not (I will not publish a new release until all those issues are fixed though, so functionally it's the same). I don't want to step on your work, but I understand you might be busy and I am keen to release a new version with the fix - let me know how you would like to proceed. Thanks! |
This is to fix a problem at startup regarding instantiation of objects. See: - #394 (comment) - https://discord.com/channels/729975036148056075/737970741324152882/784180656560275507
Hi @riccardoferretti - I was able to add a test for the new code which catches the regression with the previous code. I'll try and revise the --
|
* create commonjs modules This is to fix a problem at startup regarding instantiation of objects. See: - #394 (comment) - https://discord.com/channels/729975036148056075/737970741324152882/784180656560275507 * minor style tweaks * fix(dataviz): selected nodes must exist after updating graph data (#397) * add graph view errors to foam log
963bc1c
to
eeb4171
Compare
Doing so causes graphlib to delete the inbound links from other nodes so when this node is re-created it will be adrift by itself.
…ferenced by other notes
49bce30
to
5821ba8
Compare
This should be ready for a review now :D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
* create commonjs modules This is to fix a problem at startup regarding instantiation of objects. See: - foambubble/foam#394 (comment) - https://discord.com/channels/729975036148056075/737970741324152882/784180656560275507 * minor style tweaks * fix(dataviz): selected nodes must exist after updating graph data (#397) * add graph view errors to foam log
* create commonjs modules This is to fix a problem at startup regarding instantiation of objects. See: - foambubble/foam#394 (comment) - https://discord.com/channels/729975036148056075/737970741324152882/784180656560275507 * minor style tweaks * fix(dataviz): selected nodes must exist after updating graph data (#397) * add graph view errors to foam log
Will resolve #393
Looks like as part of
0.7.2
adeleteNote
call was added tosetNote
. (View changes)Doing so causes graphlib to delete the inbound links from other nodes so when this node is re-created it will not have its inbound links. (View relevant graphlib source)
I switched the
doDelete
back togetNote
so it still satisfies finding if the note already existed for the sake of triggering the onUpdate / onAdd events-- it seems to be behaving as expected.That said, I noticed the original approach was to delete the outbound links for the note so they can be re-created. That looked like this:
In that previous code, the actual node for the note was not being deleted nor its inbound references.
I can update this PR to restore that code if it seems necessary. Once I have feedback on that I'll check on the tests.
foam-core
foam-vscode