treymo / joplin-link-graph

UI for viewing connections between different Joplin notes
MIT License
252 stars 11 forks source link

refactor: Improve communication between plugin and ui & bundle ui #36

Closed agerardin closed 3 years ago

agerardin commented 3 years ago

The plugin is relying on a timer that triggers a full refresh every second. This impacts UI responsiveness and increase resource usage. The UI script also uses a timer to figure out when the d3 library has finished loading.

This commit addresses both issues by:

treymo commented 3 years ago

Thank you for this @agerardin!! I'll review this today or tomorrow and get it merged

agerardin commented 3 years ago

Hello! I have added d3 as a dependency in package.json. ui/index.js is declared as an extraScript in plugin.config.json so it will be bundled by webpack in a separate entry. rerun npm install should get rid of the error.

agerardin commented 3 years ago

Hello! I have updated with your remarks. The promise callback mechanism is still quite hacky but that's the best I could come out with using the current webviewAPI. I am delving into Joplin's plugin code to see how to do better but it will take some more time.

agerardin commented 3 years ago

To follow up on this, I was looking for a mechanism to send message from the plugin to the view rather than polling the plugin for changes. This is currently not implemented. I have a pull request ready for enabling push notifications so I will start discussing it with Joplin's contributors. Until this happens, the current method will do!