Potential bug and questions about the editor command: notes text & title programmatically

The use-case:
I'm developing a plugin where I do want to edit the note's body and title.
Unfortunately, the docs don't seem complete and many fields are just of any type (i.e. the Note from selectedNote() return a Promise, what type is that? What are the fields on the note etc.?)

Using await joplin.data.put(['notes', note.id], null, { body: "foo", title: "bar" }); seems to update the content but not refresh the note i.e. text is not written onto the note.

Reproduce the issue:
To understand what I mean by "not refreshed" you can reproduce:

  • Open a note
  • From your plugin, update the note's body with the joplin.data.put command while the note is opened.
  • See that the body is still empty
  • To see the updates, you'll have to Change note by clicking on another note, then change back to the initial note and see that the body now is filled

Expected Outcome:

  • The body should be filled immediately with the new body from the data.put command.

The workaround:
I checked how other plugins are handling that and saw that they are doing both:

await joplin.commands.execute("editor.setText", "foo");
await joplin.data.put(['notes', note.id], null, { body: "foo", title: "bar" });

This seems to do the job and actually write the text into the note and refresh the view (at least in the mac app, which is the only one I tried so far)

So I have a few questions:

  1. Is this non-refresh a bug?
  2. Is there a refresh command maybe or is the editor.setText approach mentioned above the correct way to handle it?
  3. There is no setTitle command that would do the same. Is it a welcome contribution to add it right now?
  4. Will the editor.setText approach work on all platforms? From what I've seen it's only in the desktop app. What about mobile?

Thank you!

Does this issue reference all of the behaviours you have seen?

Yes if that'd be fixed there would not be a need for using any command. I guess we can close this thread then and focus on the github issue thread unstead.