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

(Bug report) Frontend API in 0.61 can no longer get a note's creation date #4232

Closed
mabeyj opened this issue Sep 3, 2023 · 4 comments
Closed

Comments

@mabeyj
Copy link

mabeyj commented Sep 3, 2023

Trilium Version

0.61.5-beta

What operating system are you using?

Windows

What is your setup?

Local + server sync

Operating System Version

Windows 10 22H2

Description

Before 0.61, the Frontend API had a note.getNoteComplement method which returned an object that included the note's creation date (dateCreated and utcDateCreated):

await note.getNoteComplement()

{
    "noteId": "vfkW2wl8Mb1l",
    "content": "...",
    "contentLength": 291,
    "dateCreated": "2023-08-20 20:58:58.067-0300",
    "dateModified": "2023-08-20 20:58:58.067-0300",
    "utcDateCreated": "2023-08-20 23:58:58.067Z",
    "utcDateModified": "2023-08-20 23:58:58.067Z",
    "combinedDateModified": "2023-08-20 20:58:58.068-0300",
    "combinedUtcDateModified": "2023-08-20 23:58:58.068Z"
}

As of 0.61, note.getNoteComplement has been deprecated in favour of note.getBlob, both of which return an FBlob object. But FBlob does not have a creation date.

await note.getBlob()

{
    "blobId": "i60MtR9KeJlB68ftEBin",
    "content": "...",
    "contentLength": 291,
    "dateModified": "2023-08-20 20:58:58.036-0300",
    "utcDateModified": "2023-08-20 23:58:58.036Z"
}

There currently doesn't seem to be a (documented) way to obtain a note's creation date using the Frontend API. This breaks a use case where scripts could obtain and use the creation dates of notes (mabeyj/trilium-collection-views#41).

Can dateCreated and utcDateCreated for notes be made available somewhere in the Frontend API?

Error logs

No response

@mabeyj
Copy link
Author

mabeyj commented Sep 5, 2023

Somewhat related: There's also not an equivalent for the combinedDateModified and combinedUtcDateModified properties that were included in the Note Complement object.

I believe these were the most recent date of either the note's modified date or the content's modified date. The combined date is shown by the Note Info widget:

this.$dateModified
.text(metadata.combinedDateModified.substr(0, 16))
.attr("title", metadata.combinedDateModified);

Scripts can currently only get the blob's modified date which is not necessarily the same. Preferably when showing the date modified, I would want it to be the same one shown under Note Info.

Either dateModified/utcDateModified of the note itself or combined(Utc)DateModified properties would need to be made available as well.

@zadam
Copy link
Owner

zadam commented Sep 6, 2023

Hello, thanks for the report. The FBlob is indeed not a replacement for the previous "notecomplement". I've added a new function FNote.getMetadata(), see demo:

@zadam
Copy link
Owner

zadam commented Sep 6, 2023

Somewhat related: There's also not an equivalent for the combinedDateModified and combinedUtcDateModified properties that were included in the Note Complement object.

Indeed, but these "combined" dates are no longer necessary. The note storage approach was redesigned in 0.61, and because of that note.utcDateCreated and note.utcDateModified reflect both the note properties and the content. This is because now note object contains blobId reference. Blobs are immutable (copy on write), so if the content changes, new blobId will be used which will force note update (and therefore change of utcDateModified).

@zadam zadam closed this as completed Sep 6, 2023
@mabeyj
Copy link
Author

mabeyj commented Sep 6, 2023

Awesome, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants