mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
note revision sync fix
This commit is contained in:
parent
da92809299
commit
179d530ea9
@ -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) {
|
||||
|
@ -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.');
|
||||
}
|
||||
});
|
@ -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;
|
||||
|
@ -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');
|
||||
}
|
||||
|
@ -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>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user