Closed agerardin closed 3 years ago
Thank you for this @agerardin!! I'll review this today or tomorrow and get it merged
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.
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.
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!
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:
Replacing the first timer by a poll mechanism. When the API notifies on a change, a model change is added to a queue. The ui checks the queue for new updates and apply them. This allows for a cleaner execution model and improves responsiveness.
Using extra-scripts to bundle ui & d3 with webpack. This removes the second timer and have the side benefit of reducing the plugin's size by 5 due to treeshaking.