Skip to content

Build your personal knowledge base with Trilium Notes

note revision sync fix

zadam179d530ea975
diff --git a/src/entities/note_revision.js b/src/entities/note_revision.js
index f52afa1e74..02a6ffa8e8 100644
--- a/src/entities/note_revision.js
+++ b/src/entities/note_revision.js
@@ -130,6 +130,14 @@ class NoteRevision extends Entity {
await syncTableService.addNoteRevisionContentSync(this.noteRevisionId);
}
+ beforeSaving() {
+ super.beforeSaving();
+
+ if (this.isChanged) {
+ this.utcDateModified = dateUtils.utcNowDateTime();
+ }
+ }
+
// cannot be static!
updatePojo(pojo) {
if (pojo.isProtected) {
diff --git a/src/public/javascripts/dialogs/note_revisions.js b/src/public/javascripts/dialogs/note_revisions.js
index 9c315cb7e3..20a1660573 100644
--- a/src/public/javascripts/dialogs/note_revisions.js
+++ b/src/public/javascripts/dialogs/note_revisions.js
@@ -37,7 +37,7 @@ async function loadNoteRevisions(noteId, noteRevisionId) {
for (const item of revisionItems) {
$list.append($('<option>', {
value: item.noteRevisionId,
- text: item.dateLastEdited.substr(0, 16) + (item.isErased ? ' (erased)' : '')
+ text: item.dateLastEdited.substr(0, 16)
}));
}
@@ -60,25 +60,20 @@ $list.on('change', async () => {
$titleButtons.empty();
$content.empty();
- if (revisionItem.isErased) {
- $title.text('This revision has been erased');
- return;
- }
-
$title.html(revisionItem.title);
- const $eraseRevisionButton = $('<button class="btn btn-sm" type="button">Erase this revision</button>');
+ const $eraseRevisionButton = $('<button class="btn btn-sm" type="button">Delete this revision</button>');
$eraseRevisionButton.on('click', async () => {
const confirmDialog = await import('../dialogs/confirm.js');
- const text = 'Do you want to erase this revision? This action will erase revision title and content, but still preserve revision metadata.';
+ const text = 'Do you want to delete this revision? This action will delete revision title and content, but still preserve revision metadata.';
if (await confirmDialog.confirm(text)) {
await server.remove(`notes/${revisionItem.noteId}/revisions/${revisionItem.noteRevisionId}`);
loadNoteRevisions(revisionItem.noteId);
- toastService.showMessage('Note revision has been erased.');
+ toastService.showMessage('Note revision has been deleted.');
}
});
@@ -139,13 +134,13 @@ $list.on('change', async () => {
$eraseAllRevisionsButton.on('click', async () => {
const confirmDialog = await import('../dialogs/confirm.js');
- const text = 'Do you want to erase all revision of this note? This action will erase revision title and content, but still preserve revision metadata.';
+ const text = 'Do you want to delete all revisions of this note? This action will erase revision title and content, but still preserve revision metadata.';
if (await confirmDialog.confirm(text)) {
await server.remove(`notes/${note.noteId}/revisions`);
$dialog.modal('hide');
- toastService.showMessage('Note revisions has been erased.');
+ toastService.showMessage('Note revisions has been deleted.');
}
});
\ No newline at end of file
diff --git a/src/routes/api/note_revisions.js b/src/routes/api/note_revisions.js
index 2ce4269929..5943f150b3 100644
--- a/src/routes/api/note_revisions.js
+++ b/src/routes/api/note_revisions.js
@@ -83,6 +83,9 @@ async function downloadNoteRevision(req, res) {
res.send(await noteRevision.getContent());
}
+/**
+ * @param {NoteRevision} noteRevision
+ */
async function eraseOneNoteRevision(noteRevision) {
noteRevision.isErased = true;
noteRevision.title = null;
diff --git a/src/services/sync.js b/src/services/sync.js
index a951e4bb5c..b730e2db47 100644
--- a/src/services/sync.js
+++ b/src/services/sync.js
@@ -255,6 +255,7 @@ const primaryKeys = {
"note_contents": "noteId",
"branches": "branchId",
"note_revisions": "noteRevisionId",
+ "note_revision_contents": "noteRevisionId",
"recent_notes": "noteId",
"api_tokens": "apiTokenId",
"options": "name",
@@ -278,7 +279,7 @@ async function getEntityRow(entityName, entityId) {
throw new Error(`Entity ${entityName} ${entityId} not found.`);
}
- if (['note_contents', 'note_revisions'].includes(entityName) && entity.content !== null) {
+ if (['note_contents', 'note_revision_contents'].includes(entityName) && entity.content !== null) {
if (typeof entity.content === 'string') {
entity.content = Buffer.from(entity.content, 'UTF-8');
}
diff --git a/src/views/dialogs/note_revisions.ejs b/src/views/dialogs/note_revisions.ejs
index 32e0ad4016..c3acb367be 100644
--- a/src/views/dialogs/note_revisions.ejs
+++ b/src/views/dialogs/note_revisions.ejs
@@ -6,8 +6,8 @@
<button class="btn btn-xs"
id="note-revisions-erase-all-revisions-button"
- title="Erase all revisions of this note"
- style="padding: 0 10px 0 10px;" type="button">Erase all revisions</button>
+ title="Delete all revisions of this note"
+ style="padding: 0 10px 0 10px;" type="button">Delete all revisions</button>
<button class="help-button" type="button" data-help-page="Note-revisions" title="Help on Note revisions">?</button>