mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
provide note dates in the frontend API, fixes #4232
This commit is contained in:
parent
97d8b19868
commit
d2263c68f8
@ -211,11 +211,6 @@ class BNote extends AbstractBeccaEntity {
|
||||
return this._getContent();
|
||||
}
|
||||
|
||||
/** @returns {{dateModified, utcDateModified}} */
|
||||
getContentMetadata() {
|
||||
return sql.getRow(`SELECT dateModified, utcDateModified FROM blobs WHERE blobId = ?`, [this.blobId]);
|
||||
}
|
||||
|
||||
/** @returns {*} */
|
||||
getJsonContent() {
|
||||
const content = this.getContent();
|
||||
@ -1571,7 +1566,6 @@ class BNote extends AbstractBeccaEntity {
|
||||
saveRevision() {
|
||||
return sql.transactional(() => {
|
||||
let noteContent = this.getContent();
|
||||
const contentMetadata = this.getContentMetadata();
|
||||
|
||||
const revision = new BRevision({
|
||||
noteId: this.noteId,
|
||||
@ -1580,14 +1574,10 @@ class BNote extends AbstractBeccaEntity {
|
||||
type: this.type,
|
||||
mime: this.mime,
|
||||
isProtected: this.isProtected,
|
||||
utcDateLastEdited: this.utcDateModified > contentMetadata.utcDateModified
|
||||
? this.utcDateModified
|
||||
: contentMetadata.utcDateModified,
|
||||
utcDateLastEdited: this.utcDateModified,
|
||||
utcDateCreated: dateUtils.utcNowDateTime(),
|
||||
utcDateModified: dateUtils.utcNowDateTime(),
|
||||
dateLastEdited: this.dateModified > contentMetadata.dateModified
|
||||
? this.dateModified
|
||||
: contentMetadata.dateModified,
|
||||
dateLastEdited: this.dateModified,
|
||||
dateCreated: dateUtils.localNowDateTime()
|
||||
}, true);
|
||||
|
||||
|
@ -970,6 +970,10 @@ class FNote {
|
||||
isOptions() {
|
||||
return this.noteId.startsWith("_options");
|
||||
}
|
||||
|
||||
async getMetadata() {
|
||||
return await server.get(`notes/${this.noteId}/metadata`);
|
||||
}
|
||||
}
|
||||
|
||||
export default FNote;
|
||||
|
@ -128,8 +128,8 @@ export default class NoteInfoWidget extends NoteContextAwareWidget {
|
||||
.attr("title", metadata.dateCreated);
|
||||
|
||||
this.$dateModified
|
||||
.text(metadata.combinedDateModified.substr(0, 16))
|
||||
.attr("title", metadata.combinedDateModified);
|
||||
.text(metadata.dateModified.substr(0, 16))
|
||||
.attr("title", metadata.dateModified);
|
||||
|
||||
this.$type.text(note.type);
|
||||
|
||||
|
@ -21,11 +21,12 @@ function getNoteBlob(req) {
|
||||
|
||||
function getNoteMetadata(req) {
|
||||
const note = becca.getNoteOrThrow(req.params.noteId);
|
||||
const contentMetadata = note.getContentMetadata();
|
||||
|
||||
return {
|
||||
dateCreated: note.dateCreated,
|
||||
combinedDateModified: note.utcDateModified > contentMetadata.utcDateModified ? note.dateModified : contentMetadata.dateModified
|
||||
utcDateCreated: note.utcDateCreated,
|
||||
dateModified: note.dateModified,
|
||||
utcDateModified: note.utcDateModified,
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user