mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
sort parent relationships so that clones in search notes appear last, fixes #1686
This commit is contained in:
parent
5a173ff14e
commit
25c2db6c3a
@ -158,6 +158,26 @@ class NoteShort {
|
|||||||
return this.treeCache.getNotesFromCache(this.parents);
|
return this.treeCache.getNotesFromCache(this.parents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// will sort the parents so that non-search & non-archived are first and archived at the end
|
||||||
|
// this is done so that non-search & non-archived paths are always explored as first when looking for note path
|
||||||
|
resortParents() {
|
||||||
|
this.parents.sort((aNoteId, bNoteId) => {
|
||||||
|
const aBranchId = this.parentToBranch[aNoteId];
|
||||||
|
|
||||||
|
if (aBranchId && aBranchId.startsWith('virt-')) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const aNote = this.treeCache.getNoteFromCache([aNoteId]);
|
||||||
|
|
||||||
|
if (aNote.hasLabel('archived')) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/** @returns {string[]} */
|
/** @returns {string[]} */
|
||||||
getChildNoteIds() {
|
getChildNoteIds() {
|
||||||
return this.children;
|
return this.children;
|
||||||
|
@ -56,6 +56,8 @@ async function resolveNotePathToSegments(notePath, logErrors = true) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
child.resortParents();
|
||||||
|
|
||||||
const parents = child.getParentNotes();
|
const parents = child.getParentNotes();
|
||||||
|
|
||||||
if (!parents.length) {
|
if (!parents.length) {
|
||||||
|
@ -180,10 +180,14 @@ class Note {
|
|||||||
return !!this.ownedAttributes.find(attr => attr.type === 'label' && attr.name === 'archived' && attr.isInheritable);
|
return !!this.ownedAttributes.find(attr => attr.type === 'label' && attr.name === 'archived' && attr.isInheritable);
|
||||||
}
|
}
|
||||||
|
|
||||||
// will sort the parents so that non-archived are first and archived at the end
|
// will sort the parents so that non-search & non-archived are first and archived at the end
|
||||||
// this is done so that non-archived paths are always explored as first when searching for note path
|
// this is done so that non-search & non-archived paths are always explored as first when looking for note path
|
||||||
resortParents() {
|
resortParents() {
|
||||||
this.parents.sort((a, b) => a.hasInheritableOwnedArchivedLabel ? 1 : -1);
|
this.parentBranches.sort((a, b) =>
|
||||||
|
a.branchId.startsWith('virt-')
|
||||||
|
|| a.parentNote.hasInheritableOwnedArchivedLabel ? 1 : -1);
|
||||||
|
|
||||||
|
this.parents = this.parentBranches.map(branch => branch.parentNote);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user