-
I have another strange thing happening... I have a note which contains some json data. I have successfully (with help from some great people here) loaded this data into my FrontendJS app I am writing. For changes that are made, I need to then take that changed JSON and save it back to the original note. However, something very strange is happening. Here is the function that is trying to save the data:
The note id passed in is ln7hIzdFYEVh. However, when I attempt to save, I am getting this error:
hK6Czvugwyhl is a completely different note. It is a note I deleted this afternoon. I did an integrity fix, a consistency check and a DB vacuum and now I get the same error but with ID 66nQiUxkVkJx. That is the ID of the SQL Console I had just used to find out what the previous ID was. My confusion is this... It seems that an id gets "stuck" and when I call getContents with an ID, it is ignoring that and using a cached ID. Anyone else seen this? I am using the stable release (60.4) on an Ubuntu server running the Trilium Docker instance. I have https all set and working, but no sync enabled (only using the web interface). Thanks in advance, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Try doing something like this: async function setNoteContent(noteID, content) {
await api.runOnBackend((id, newContent) => {
const targetNote = api.getNote(id);
targetNote.setContent(newContent, null);
}, [noteID, content]);
await api.waitUntilSynced();
} Think of the function you pass as being stringified (because it is), so the wrapping function's parameters are not actually in scope when the function runs. Edit: Updated the variables to be different to show that they are in fact not connected at all. |
Beta Was this translation helpful? Give feedback.
runOnBackend
takes two arguments, the function to run, and thearguments
array to pass to said function. You need to pass your arguments in so they can be serialized over to the backend context.Try doing something like this:
Think of the function you pass as being stringified (because it is), so the wrapping function's parameters are not actually in scope when the function runs.
Edit: Updated the varia…