mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 19:36:12 +01:00
undelete note WIP
This commit is contained in:
@@ -71,6 +71,16 @@ async function deleteNote(req) {
|
||||
}
|
||||
}
|
||||
|
||||
async function undeleteNote(req) {
|
||||
const note = await repository.getNote(req.params.noteId);
|
||||
|
||||
const taskContext = TaskContext.getInstance(utils.randomString(), 'undelete-notes');
|
||||
|
||||
await noteService.undeleteNote(note, note.deleteId, taskContext);
|
||||
|
||||
await taskContext.taskSucceeded();
|
||||
}
|
||||
|
||||
async function sortNotes(req) {
|
||||
const noteId = req.params.noteId;
|
||||
|
||||
@@ -172,6 +182,7 @@ module.exports = {
|
||||
getNote,
|
||||
updateNote,
|
||||
deleteNote,
|
||||
undeleteNote,
|
||||
createNote,
|
||||
sortNotes,
|
||||
protectSubtree,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
const sql = require('../../services/sql');
|
||||
const protectedSessionService = require('../../services/protected_session');
|
||||
const noteService = require('../../services/notes');
|
||||
|
||||
async function getRecentChanges() {
|
||||
const recentChanges = await sql.getRows(
|
||||
@@ -60,17 +61,10 @@ async function getRecentChanges() {
|
||||
else {
|
||||
const deleteId = change.current_deleteId;
|
||||
|
||||
const undeletedParentCount = await sql.getValue(`
|
||||
SELECT COUNT(parentNote.noteId)
|
||||
FROM branches
|
||||
JOIN notes AS parentNote ON parentNote.noteId = branches.parentNoteId
|
||||
WHERE branches.noteId = ?
|
||||
AND branches.isDeleted = 1
|
||||
AND branches.deleteId = ?
|
||||
AND parentNote.isDeleted = 0`, [change.noteId, deleteId]);
|
||||
const undeletedParentBranches = await noteService.getUndeletedParentBranches(change.noteId, deleteId);
|
||||
|
||||
// note (and the subtree) can be undeleted if there's at least one undeleted parent (whose branch would be undeleted by this op)
|
||||
change.canBeUndeleted = undeletedParentCount > 0;
|
||||
change.canBeUndeleted = undeletedParentBranches.length > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user