From 5a2907b670c242fd0519095eb81046c057a2211c Mon Sep 17 00:00:00 2001 From: zadam Date: Sat, 24 Dec 2022 13:15:19 +0100 Subject: [PATCH] delete preview takes into account strong/weak branches --- src/public/app/components/tab_manager.js | 2 +- src/routes/api/notes.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/public/app/components/tab_manager.js b/src/public/app/components/tab_manager.js index 2e3bd6ec3..5c71ed558 100644 --- a/src/public/app/components/tab_manager.js +++ b/src/public/app/components/tab_manager.js @@ -413,7 +413,7 @@ export default class TabManager extends Component { return; } - this.recentlyClosedTabs.push(noteContexts);console.log(this.recentlyClosedTabs); + this.recentlyClosedTabs.push(noteContexts); } tabReorderEvent({ntxIdsInOrder}) { diff --git a/src/routes/api/notes.js b/src/routes/api/notes.js index 4268b7d4d..5fefc123e 100644 --- a/src/routes/api/notes.js +++ b/src/routes/api/notes.js @@ -235,15 +235,19 @@ function getDeleteNotesPreview(req) { const {branchIdsToDelete, deleteAllClones} = req.body; const noteIdsToBeDeleted = new Set(); - const branchCountToDelete = {}; // noteId => count (integer) + const strongBranchCountToDelete = {}; // noteId => count (integer) function branchPreviewDeletion(branch) { - branchCountToDelete[branch.branchId] = branchCountToDelete[branch.branchId] || 0; - branchCountToDelete[branch.branchId]++; + if (branch.isWeak) { + return; + } + + strongBranchCountToDelete[branch.branchId] = strongBranchCountToDelete[branch.branchId] || 0; + strongBranchCountToDelete[branch.branchId]++; const note = branch.getNote(); - if (deleteAllClones || note.getParentBranches().length <= branchCountToDelete[branch.branchId]) { + if (deleteAllClones || note.getStrongParentBranches().length <= strongBranchCountToDelete[branch.branchId]) { noteIdsToBeDeleted.add(note.noteId); for (const childBranch of note.getChildBranches()) {