mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +01:00 
			
		
		
		
	refactoring
This commit is contained in:
		
							parent
							
								
									2e794ee38f
								
							
						
					
					
						commit
						63e044ffdf
					
				@ -82,41 +82,7 @@ function getNoteTitleForPath(notePathArray) {
 | 
				
			|||||||
    return titles.join(' / ');
 | 
					    return titles.join(' / ');
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function getNotePath(noteId) {
 | 
					 | 
				
			||||||
    const note = becca.notes[noteId];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (!note) {
 | 
					 | 
				
			||||||
        console.trace(`Cannot find note '${noteId}'.`);
 | 
					 | 
				
			||||||
        return;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    const retPath = note.getBestNotePath();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (retPath) {
 | 
					 | 
				
			||||||
        const noteTitle = getNoteTitleForPath(retPath);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        let branchId;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (note.isRoot()) {
 | 
					 | 
				
			||||||
            branchId = 'none_root';
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            const parentNote = note.parents[0];
 | 
					 | 
				
			||||||
            branchId = becca.getBranchFromChildAndParent(noteId, parentNote.noteId).branchId;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return {
 | 
					 | 
				
			||||||
            noteId: noteId,
 | 
					 | 
				
			||||||
            branchId: branchId,
 | 
					 | 
				
			||||||
            title: noteTitle,
 | 
					 | 
				
			||||||
            notePath: retPath,
 | 
					 | 
				
			||||||
            path: retPath.join('/')
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
module.exports = {
 | 
					module.exports = {
 | 
				
			||||||
    getNotePath,
 | 
					 | 
				
			||||||
    getNoteTitle,
 | 
					    getNoteTitle,
 | 
				
			||||||
    getNoteTitleForPath,
 | 
					    getNoteTitleForPath,
 | 
				
			||||||
    isNotePathArchived
 | 
					    isNotePathArchived
 | 
				
			||||||
 | 
				
			|||||||
@ -135,7 +135,7 @@ function getEditedNotesOnDate(req) {
 | 
				
			|||||||
    notes = notes.map(note => note.getPojo());
 | 
					    notes = notes.map(note => note.getPojo());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for (const note of notes) {
 | 
					    for (const note of notes) {
 | 
				
			||||||
        const notePath = note.isDeleted ? null : beccaService.getNotePath(note.noteId);
 | 
					        const notePath = note.isDeleted ? null : getNotePathData(note);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        note.notePath = notePath ? notePath.notePath : null;
 | 
					        note.notePath = notePath ? notePath.notePath : null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -143,6 +143,32 @@ function getEditedNotesOnDate(req) {
 | 
				
			|||||||
    return notes;
 | 
					    return notes;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function getNotePathData(note) {
 | 
				
			||||||
 | 
					    const retPath = note.getBestNotePath();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (retPath) {
 | 
				
			||||||
 | 
					        const noteTitle = beccaService.getNoteTitleForPath(retPath);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        let branchId;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (note.isRoot()) {
 | 
				
			||||||
 | 
					            branchId = 'none_root';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else {
 | 
				
			||||||
 | 
					            const parentNote = note.parents[0];
 | 
				
			||||||
 | 
					            branchId = becca.getBranchFromChildAndParent(note.noteId, parentNote.noteId).branchId;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return {
 | 
				
			||||||
 | 
					            noteId: note.noteId,
 | 
				
			||||||
 | 
					            branchId: branchId,
 | 
				
			||||||
 | 
					            title: noteTitle,
 | 
				
			||||||
 | 
					            notePath: retPath,
 | 
				
			||||||
 | 
					            path: retPath.join('/')
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
module.exports = {
 | 
					module.exports = {
 | 
				
			||||||
    getNoteRevisions,
 | 
					    getNoteRevisions,
 | 
				
			||||||
    getNoteRevision,
 | 
					    getNoteRevision,
 | 
				
			||||||
 | 
				
			|||||||
@ -40,7 +40,7 @@ function cloneNoteToParentNote(noteId, parentNoteId, prefix) {
 | 
				
			|||||||
    return {
 | 
					    return {
 | 
				
			||||||
        success: true,
 | 
					        success: true,
 | 
				
			||||||
        branchId: branch.branchId,
 | 
					        branchId: branch.branchId,
 | 
				
			||||||
        notePath: `${beccaService.getNotePath(parentNoteId).path}/${noteId}`
 | 
					        notePath: `${parentNote.getBestNotePathString()}/${noteId}`
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -26,8 +26,6 @@ class NoteFlatTextExp extends Expression {
 | 
				
			|||||||
            if (tokens.length === 0) {
 | 
					            if (tokens.length === 0) {
 | 
				
			||||||
                const retPath = this.getNotePath(note, path);
 | 
					                const retPath = this.getNotePath(note, path);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                console.log(retPath);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (retPath) {
 | 
					                if (retPath) {
 | 
				
			||||||
                    const noteId = retPath[retPath.length - 1];
 | 
					                    const noteId = retPath[retPath.length - 1];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user