mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	fixes to recent changes
This commit is contained in:
		| @@ -33,9 +33,18 @@ const recentChanges = (function() { | |||||||
|                     .attr('note-path', change.note_id) |                     .attr('note-path', change.note_id) | ||||||
|                     .attr('note-history-id', change.note_history_id); |                     .attr('note-history-id', change.note_history_id); | ||||||
|  |  | ||||||
|  |                 let noteLink; | ||||||
|  |  | ||||||
|  |                 if (change.current_is_deleted) { | ||||||
|  |                     noteLink = change.current_note_title; | ||||||
|  |                 } | ||||||
|  |                 else { | ||||||
|  |                     noteLink = link.createNoteLink(change.note_id, change.note_title); | ||||||
|  |                 } | ||||||
|  |  | ||||||
|                 changesListEl.append($('<li>') |                 changesListEl.append($('<li>') | ||||||
|                     .append(formattedTime + ' - ') |                     .append(formattedTime + ' - ') | ||||||
|                     .append(link.createNoteLink(change.note_id)) |                     .append(noteLink) | ||||||
|                     .append(' (').append(revLink).append(')')); |                     .append(' (').append(revLink).append(')')); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -184,7 +184,32 @@ const noteTree = (function() { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     async function activateNode(notePath) { |     async function activateNode(notePath) { | ||||||
|  |         const runPath = getRunPath(notePath); | ||||||
|  |         const noteId = treeUtils.getNoteIdFromNotePath(notePath); | ||||||
|  |  | ||||||
|  |         let parentNoteId = 'root'; | ||||||
|  |  | ||||||
|  |         for (const childNoteId of runPath) { | ||||||
|  |             const node = getNodesByNoteId(childNoteId).find(node => node.data.note_pid === parentNoteId); | ||||||
|  |  | ||||||
|  |             if (childNoteId === noteId) { | ||||||
|  |                 await node.setActive(); | ||||||
|  |             } | ||||||
|  |             else { | ||||||
|  |                 await node.setExpanded(); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |             parentNoteId = childNoteId; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * Accepts notePath and tries to resolve it. Part of the path might not be valid because of note moving (which causes | ||||||
|  |      * path change) or other corruption, in that case this will try to get some other valid path to the correct note. | ||||||
|  |      */ | ||||||
|  |     function getRunPath(notePath) { | ||||||
|         const path = notePath.split("/").reverse(); |         const path = notePath.split("/").reverse(); | ||||||
|  |         path.push('root'); | ||||||
|  |  | ||||||
|         const effectivePath = []; |         const effectivePath = []; | ||||||
|         let childNoteId = null; |         let childNoteId = null; | ||||||
| @@ -224,27 +249,16 @@ const noteTree = (function() { | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             effectivePath.push(parentNoteId); |             if (parentNoteId === 'root') { | ||||||
|             childNoteId = parentNoteId; |                 break; | ||||||
|         } |  | ||||||
|  |  | ||||||
|         const noteId = treeUtils.getNoteIdFromNotePath(notePath); |  | ||||||
|  |  | ||||||
|         const runPath = effectivePath.reverse(); |  | ||||||
|         let parentNoteId = 'root'; |  | ||||||
|  |  | ||||||
|         for (const childNoteId of runPath) { |  | ||||||
|             const node = getNodesByNoteId(childNoteId).find(node => node.data.note_pid === parentNoteId); |  | ||||||
|  |  | ||||||
|             if (childNoteId === noteId) { |  | ||||||
|                 await node.setActive(); |  | ||||||
|             } |             } | ||||||
|             else { |             else { | ||||||
|                 await node.setExpanded(); |                 effectivePath.push(parentNoteId); | ||||||
|  |                 childNoteId = parentNoteId; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             parentNoteId = childNoteId; |  | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         return effectivePath.reverse(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     function showParentList(noteId, node) { |     function showParentList(noteId, node) { | ||||||
|   | |||||||
| @@ -6,7 +6,17 @@ const sql = require('../../services/sql'); | |||||||
| const auth = require('../../services/auth'); | const auth = require('../../services/auth'); | ||||||
|  |  | ||||||
| router.get('/', auth.checkApiAuth, async (req, res, next) => { | router.get('/', auth.checkApiAuth, async (req, res, next) => { | ||||||
|     const recentChanges = await sql.getResults("SELECT * FROM notes_history order by date_modified_to desc limit 1000"); |     const recentChanges = await sql.getResults( | ||||||
|  |         `SELECT  | ||||||
|  |             notes.is_deleted AS current_is_deleted, | ||||||
|  |             notes.note_title AS current_note_title, | ||||||
|  |             notes_history.* | ||||||
|  |         FROM  | ||||||
|  |             notes_history | ||||||
|  |             JOIN notes USING(note_id) | ||||||
|  |         ORDER BY  | ||||||
|  |             date_modified_to DESC  | ||||||
|  |         LIMIT 1000`); | ||||||
|  |  | ||||||
|     res.send(recentChanges); |     res.send(recentChanges); | ||||||
| }); | }); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user