Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(client): wrap lines over 100 characters in the delete-navigation change
perfectra1n885002aa5b29
diff --git a/apps/client/src/services/branches.spec.ts b/apps/client/src/services/branches.spec.tsindex 1e29d84bab..267fcf7577 100644--- a/apps/client/src/services/branches.spec.ts+++ b/apps/client/src/services/branches.spec.ts@@ -307,7 +307,7 @@ describe("deleteNotes", () => {});describe("activateNeighbouringNotePath (via deleteNotes navigation)", () => {- /** Confirms the delete dialog with the given options and captures where the active tab navigates. */+ /** Confirms the delete dialog with the given options and captures where the tab navigates. */function confirmDeletion(notePathArray: string[], deleteAllClones = false) {const setNote = vi.fn(async () => {});appContext.tabManager = {@@ -319,9 +319,12 @@ describe("activateNeighbouringNotePath (via deleteNotes navigation)", () => {return setNote;}- it("activates the next sibling, or the previous one when the deleted note is the last", async () => {+ it("activates the next sibling, or the previous one for the last note", async () => {const parent = buildNote({ title: "P", children: [- { id: "sibA", title: "A" }, { id: "sibB", title: "B" }, { id: "sibC", title: "C" }, { id: "sibD", title: "D" }+ { id: "sibA", title: "A" },+ { id: "sibB", title: "B" },+ { id: "sibC", title: "C" },+ { id: "sibD", title: "D" }] });const p = parent.noteId;@@ -340,9 +343,11 @@ describe("activateNeighbouringNotePath (via deleteNotes navigation)", () => {expect(setNote).toHaveBeenCalledWith(`root/${p}/sibB`);});- it("skips siblings that the deletion also removes and archived ones, falling back to the parent", async () => {+ it("skips removed and archived siblings, falling back to the parent", async () => {const parent = buildNote({ title: "P2", children: [- { id: "arcA", title: "A", "#archived": "" }, { id: "selB", title: "B" }, { id: "selC", title: "C" }+ { id: "arcA", title: "A", "#archived": "" },+ { id: "selB", title: "B" },+ { id: "selC", title: "C" }] });const p = parent.noteId;@@ -425,8 +430,9 @@ describe("activateNeighbouringNotePath (via deleteNotes navigation)", () => {getActiveContext: () => ({ notePathArray: undefined, setNote })} as any;appContext.triggerCommand = vi.fn((_name: any, data: any) => {- // Remove the branch after filtering but before navigation, so activateNeighbouringNotePath's- // `froca.getBranch(...)` returns undefined and the `if (branch)` false arm is taken.+ // Remove the branch after filtering but before navigation, so that+ // activateNeighbouringNotePath's `froca.getBranch(...)` returns undefined and the+ // `if (branch)` false arm is taken.delete froca.branches["ancBranch"];data.callback({ proceed: true, deleteAllClones: false, eraseNotes: false });}) as any;diff --git a/apps/client/src/services/branches.ts b/apps/client/src/services/branches.tsindex 2401f4154b..6c057b20df 100644--- a/apps/client/src/services/branches.ts+++ b/apps/client/src/services/branches.ts@@ -184,7 +184,12 @@ async function activateNeighbouringNotePath(branchIdsToDelete: string[], deleteAreturn;}- const siblingNoteId = findSurvivingSibling(parentPath[parentPath.length - 1], activeNotePath[earliestIndex], branchIdsToDelete, deleteAllClones);+ const siblingNoteId = findSurvivingSibling(+ parentPath[parentPath.length - 1],+ activeNotePath[earliestIndex],+ branchIdsToDelete,+ deleteAllClones+ );const targetPath = siblingNoteId ? [ ...parentPath, siblingNoteId ] : parentPath;await activeContext?.setNote(targetPath.join("/"));}@@ -194,7 +199,12 @@ async function activateNeighbouringNotePath(branchIdsToDelete: string[], deleteA* are deleted: the next sibling, else the previous one. Archived siblings are skipped, since the* tree can be set to hide them.*/-function findSurvivingSibling(parentNoteId: string, noteId: string, branchIdsToDelete: string[], deleteAllClones: boolean) {+function findSurvivingSibling(+ parentNoteId: string,+ noteId: string,+ branchIdsToDelete: string[],+ deleteAllClones: boolean+) {const parentNote = froca.getNoteFromCache(parentNoteId);if (!parentNote) {return null;@@ -207,13 +217,18 @@ function findSurvivingSibling(parentNoteId: string, noteId: string, branchIdsToD}// Deleting all clones removes every branch of the deleted notes, not only the selected ones.- const deletedNoteIds = new Set(branchIdsToDelete.map((branchId) => froca.getBranch(branchId)?.noteId));+ const deletedNoteIds = new Set(+ branchIdsToDelete.map((branchId) => froca.getBranch(branchId)?.noteId)+ );const survives = (branch: FBranch) =>!branchIdsToDelete.includes(branch.branchId)&& !(deleteAllClones && deletedNoteIds.has(branch.noteId))&& !froca.getNoteFromCache(branch.noteId)?.isArchived;- const candidates = [ ...siblingBranches.slice(index + 1), ...siblingBranches.slice(0, index).reverse() ];+ const candidates = [+ ...siblingBranches.slice(index + 1),+ ...siblingBranches.slice(0, index).reverse()+ ];return candidates.find(survives)?.noteId ?? null;}diff --git a/apps/client/src/services/focus.spec.ts b/apps/client/src/services/focus.spec.tsindex fdf7a25f38..9fb4f8384b 100644--- a/apps/client/src/services/focus.spec.ts+++ b/apps/client/src/services/focus.spec.ts@@ -11,9 +11,9 @@ afterEach(() => {describe("focus service", () => {it("does nothing (no focus change) when nothing was focused at save time", () => {// saveFocusedElement() always assigns a jQuery object: $(":focus") is never null, only an- // empty wrapped set (or, under happy-dom, the <body> itself). So the early-return at the top- // of focusSavedElement() is NOT hit here; execution falls through to .hasClass("ck") (false)- // and then to a focus() that changes nothing.+ // empty wrapped set (or, under happy-dom, the <body> itself). So the early-return at the+ // top of focusSavedElement() is NOT hit here; execution falls through to .hasClass("ck")+ // (false) and then to a focus() that changes nothing.const $body = $(document.body);($body[0] as HTMLElement).focus();// happy-dom keeps focus on <body> by default; record the active element to prove it is unchanged.