mirror of
https://github.com/zadam/trilium.git
synced 2025-11-16 10:15:52 +01:00
Merge branch 'master' into next60
This commit is contained in:
@@ -79,14 +79,10 @@ async function resolveNotePathToSegments(notePath, hoistedNoteId = 'root', logEr
|
||||
You can ignore this message as it is mostly harmless.`);
|
||||
}
|
||||
|
||||
const someNotePath = getSomeNotePath(child, hoistedNoteId);
|
||||
const bestNotePath = child.getBestNotePath(hoistedNoteId);
|
||||
|
||||
if (someNotePath) { // in case it's root the path may be empty
|
||||
const pathToRoot = someNotePath.split("/").reverse().slice(1);
|
||||
|
||||
if (!pathToRoot.includes("root")) {
|
||||
pathToRoot.push('root');
|
||||
}
|
||||
if (bestNotePath) {
|
||||
const pathToRoot = bestNotePath.reverse().slice(1);
|
||||
|
||||
for (const noteId of pathToRoot) {
|
||||
effectivePathSegments.push(noteId);
|
||||
@@ -109,31 +105,17 @@ async function resolveNotePathToSegments(notePath, hoistedNoteId = 'root', logEr
|
||||
else {
|
||||
const note = await froca.getNote(getNoteIdFromNotePath(notePath));
|
||||
|
||||
const someNotePathSegments = getSomeNotePathSegments(note, hoistedNoteId);
|
||||
const bestNotePath = note.getBestNotePath(hoistedNoteId);
|
||||
|
||||
if (!someNotePathSegments) {
|
||||
throw new Error(`Did not find any path segments for ${note.toString()}, hoisted note ${hoistedNoteId}`);
|
||||
if (!bestNotePath) {
|
||||
throw new Error(`Did not find any path segments for '${note.toString()}', hoisted note '${hoistedNoteId}'`);
|
||||
}
|
||||
|
||||
// if there isn't actually any note path with hoisted note then return the original resolved note path
|
||||
return someNotePathSegments.includes(hoistedNoteId) ? someNotePathSegments : effectivePathSegments;
|
||||
return bestNotePath.includes(hoistedNoteId) ? bestNotePath : effectivePathSegments;
|
||||
}
|
||||
}
|
||||
|
||||
function getSomeNotePathSegments(note, hoistedNotePath = 'root') {
|
||||
utils.assertArguments(note);
|
||||
|
||||
const notePaths = note.getSortedNotePaths(hoistedNotePath);
|
||||
|
||||
return notePaths.length > 0 ? notePaths[0].notePath : null;
|
||||
}
|
||||
|
||||
function getSomeNotePath(note, hoistedNotePath = 'root') {
|
||||
const notePath = getSomeNotePathSegments(note, hoistedNotePath);
|
||||
|
||||
return notePath === null ? null : notePath.join('/');
|
||||
}
|
||||
|
||||
ws.subscribeToMessages(message => {
|
||||
if (message.type === 'openNote') {
|
||||
appContext.tabManager.activateOrOpenNote(message.noteId);
|
||||
@@ -341,16 +323,6 @@ function isNotePathInAddress() {
|
||||
|| (notePath === '' && !!ntxId);
|
||||
}
|
||||
|
||||
function parseNotePath(notePath) {
|
||||
let noteIds = notePath.split('/');
|
||||
|
||||
if (noteIds[0] !== 'root') {
|
||||
noteIds = ['root'].concat(noteIds);
|
||||
}
|
||||
|
||||
return noteIds;
|
||||
}
|
||||
|
||||
function isNotePathInHiddenSubtree(notePath) {
|
||||
return notePath?.includes("root/_hidden");
|
||||
}
|
||||
@@ -358,8 +330,6 @@ function isNotePathInHiddenSubtree(notePath) {
|
||||
export default {
|
||||
resolveNotePath,
|
||||
resolveNotePathToSegments,
|
||||
getSomeNotePath,
|
||||
getSomeNotePathSegments,
|
||||
getParentProtectedStatus,
|
||||
getNotePath,
|
||||
getNoteIdFromNotePath,
|
||||
@@ -370,6 +340,5 @@ export default {
|
||||
getNoteTitleWithPathAsSuffix,
|
||||
parseNavigationStateFromAddress,
|
||||
isNotePathInAddress,
|
||||
parseNotePath,
|
||||
isNotePathInHiddenSubtree
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user