Skip to content
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

Desktop: Re-render note when resources are changed #10459

Conversation

personalizedrefrigerator
Copy link
Collaborator

@personalizedrefrigerator personalizedrefrigerator commented May 22, 2024

Summary

This pull request causes notes to be re-rendered when resources change. This is intended specifically to show changes to resources through the plugin/data API, but also applies to other changes made with Resource.save.

Notes

  • Previously, notes would re-render when resources changed, but only in certain cases: when watched by the ResourceEditWatcher, when finished downloading/decrypting, and when download starts. This did not handle the case where a resource is updated through the data API.
  • This allows removing an only-partially-working workaround in the Freehand Drawing plugin.
  • This may be important for Desktop: File system mirroring #10448 when resource mirroring is implemented.

Testing plan

In addition to this pull request's automated test, this can be tested by:

  1. Installing the Freehand Drawing plugin (if not already installed)
  2. Adding a new drawing
  3. Selecting the drawing's resource ID
  4. Opening the command palette and running :insertDrawing__newWindow
    • Prior to this pull request, changes made in a new window were not reflected in the note viewer without switching notes.
  5. Making a change to the drawing
  6. Clicking "save"
  7. Verifying that the drawing updates

This has been tested successfully on Ubuntu 24.04.

@@ -637,7 +637,7 @@ export default class Resource extends BaseItem {
}

const output = await super.save(resource, options);
if (isNew) eventManager.emit(EventName.ResourceCreate);
eventManager.emit(isNew ? EventName.ResourceCreate : EventName.ResourceChange, { id: output.id });
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request also causes ResourceChange events to be emitted when a resource's metadata changes. Previously, ResourceChange events were fired only while resources were being watched.

personalizedrefrigerator added a commit to personalizedrefrigerator/joplin that referenced this pull request May 22, 2024
Related to laurent22#10459, but needs
more testing -- this change could cause regressions.
@personalizedrefrigerator personalizedrefrigerator added desktop All desktop platforms editor and removed editor labels May 24, 2024
@laurent22 laurent22 merged commit b8caf08 into laurent22:dev May 28, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
desktop All desktop platforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants