mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
fix for moving the notes
This commit is contained in:
parent
df27533b66
commit
b3c32a39e9
@ -49,8 +49,15 @@ class TreeCache {
|
|||||||
return this.branches[branchId];
|
return this.branches[branchId];
|
||||||
}
|
}
|
||||||
|
|
||||||
getBranchByParentChild(childNoteId, parentNoteId) {
|
getBranchByChildParent(childNoteId, parentNoteId) {
|
||||||
return this.childParentToBranch[childNoteId + '-' + parentNoteId];
|
const key = (childNoteId + '-' + parentNoteId);
|
||||||
|
const branch = this.childParentToBranch[key];
|
||||||
|
|
||||||
|
if (!branch) {
|
||||||
|
utils.throwError("Cannot find branch for child-parent=" + key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return branch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +76,7 @@ class NoteShort {
|
|||||||
const branches = [];
|
const branches = [];
|
||||||
|
|
||||||
for (const parent of this.treeCache.parents[this.noteId]) {
|
for (const parent of this.treeCache.parents[this.noteId]) {
|
||||||
branches.push(await this.treeCache.getBranchByParentChild(this.noteId, p.noteId));
|
branches.push(await this.treeCache.getBranchByChildParent(this.noteId, p.noteId));
|
||||||
}
|
}
|
||||||
|
|
||||||
return branches;
|
return branches;
|
||||||
@ -79,7 +86,7 @@ class NoteShort {
|
|||||||
const branches = [];
|
const branches = [];
|
||||||
|
|
||||||
for (const child of this.treeCache.children[this.noteId]) {
|
for (const child of this.treeCache.children[this.noteId]) {
|
||||||
branches.push(await this.treeCache.getBranchByParentChild(child.noteId, this.noteId));
|
branches.push(await this.treeCache.getBranchByChildParent(child.noteId, this.noteId));
|
||||||
}
|
}
|
||||||
|
|
||||||
return branches;
|
return branches;
|
||||||
@ -149,7 +156,7 @@ const treeService = (function() {
|
|||||||
let title = treeCache.getNote(noteId).title;
|
let title = treeCache.getNote(noteId).title;
|
||||||
|
|
||||||
if (parentNoteId !== null) {
|
if (parentNoteId !== null) {
|
||||||
const branch = treeCache.getBranchByParentChild(noteId, parentNoteId);
|
const branch = treeCache.getBranchByChildParent(noteId, parentNoteId);
|
||||||
|
|
||||||
if (branch && branch.prefix) {
|
if (branch && branch.prefix) {
|
||||||
title = branch.prefix + ' - ' + title;
|
title = branch.prefix + ' - ' + title;
|
||||||
@ -207,10 +214,20 @@ const treeService = (function() {
|
|||||||
function removeParentChildRelation(parentNoteId, childNoteId) {
|
function removeParentChildRelation(parentNoteId, childNoteId) {
|
||||||
utils.assertArguments(parentNoteId, childNoteId);
|
utils.assertArguments(parentNoteId, childNoteId);
|
||||||
|
|
||||||
const parentNote = noteMap[parentNoteId];
|
treeCache.parents[childNoteId] = treeCache.parents[childNoteId].filter(p => p.noteId !== parentNoteId);
|
||||||
const childNote = noteMap[childNoteId];
|
treeCache.children[parentNoteId] = treeCache.children[parentNoteId].filter(ch => ch.noteId !== childNoteId);
|
||||||
|
|
||||||
// FIXME
|
delete treeCache.childParentToBranch[childNoteId + '-' + parentNoteId];
|
||||||
|
}
|
||||||
|
|
||||||
|
function setParentChildRelation(branchId, parentNoteId, childNoteId) {
|
||||||
|
treeCache.parents[childNoteId] = treeCache.parents[childNoteId] || [];
|
||||||
|
treeCache.parents[childNoteId].push(treeCache.getNote(parentNoteId));
|
||||||
|
|
||||||
|
treeCache.children[parentNoteId] = treeCache.children[parentNoteId] || [];
|
||||||
|
treeCache.children[parentNoteId].push(treeCache.getNote(childNoteId));
|
||||||
|
|
||||||
|
treeCache.childParentToBranch[childNoteId + '-' + parentNoteId] = treeCache.getBranch(branchId);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function prepareBranch(noteRows, branchRows) {
|
async function prepareBranch(noteRows, branchRows) {
|
||||||
@ -736,7 +753,7 @@ const treeService = (function() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return await prepareBranchInner(searchNoteId);
|
return await prepareBranchInner(treeCache.getNote(searchNoteId));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTree() {
|
function getTree() {
|
||||||
@ -1022,6 +1039,7 @@ const treeService = (function() {
|
|||||||
setPrefix,
|
setPrefix,
|
||||||
getNotePathTitle,
|
getNotePathTitle,
|
||||||
removeParentChildRelation,
|
removeParentChildRelation,
|
||||||
|
setParentChildRelation,
|
||||||
getSelectedNodes,
|
getSelectedNodes,
|
||||||
sortAlphabetically,
|
sortAlphabetically,
|
||||||
noteExists,
|
noteExists,
|
||||||
|
@ -117,7 +117,6 @@ const treeChanges = (function() {
|
|||||||
|
|
||||||
node.data.parentNoteId = utils.isTopLevelNode(node) ? 'root' : node.getParent().data.noteId;
|
node.data.parentNoteId = utils.isTopLevelNode(node) ? 'root' : node.getParent().data.noteId;
|
||||||
|
|
||||||
// FIXME!!!
|
|
||||||
treeService.setParentChildRelation(node.data.branchId, node.data.parentNoteId, node.data.noteId);
|
treeService.setParentChildRelation(node.data.branchId, node.data.parentNoteId, node.data.noteId);
|
||||||
|
|
||||||
treeService.setCurrentNotePathToHash(node);
|
treeService.setCurrentNotePathToHash(node);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user