mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 13:01:31 +08:00 
			
		
		
		
	recent changes now display also newly created notes without any revisions, some extra improvements to the dialog
This commit is contained in:
		
							parent
							
								
									a981df6282
								
							
						
					
					
						commit
						a6f57d7761
					
				| @ -1,6 +1,8 @@ | |||||||
| import linkService from '../services/link.js'; | import linkService from '../services/link.js'; | ||||||
| import utils from '../services/utils.js'; | import utils from '../services/utils.js'; | ||||||
| import server from '../services/server.js'; | import server from '../services/server.js'; | ||||||
|  | import treeService from "../services/tree.js"; | ||||||
|  | import treeCache from "../services/tree_cache.js"; | ||||||
| 
 | 
 | ||||||
| const $dialog = $("#recent-changes-dialog"); | const $dialog = $("#recent-changes-dialog"); | ||||||
| const $content = $("#recent-changes-content"); | const $content = $("#recent-changes-content"); | ||||||
| @ -14,6 +16,9 @@ export async function showDialog() { | |||||||
| 
 | 
 | ||||||
|     const result = await server.get('recent-changes'); |     const result = await server.get('recent-changes'); | ||||||
| 
 | 
 | ||||||
|  |     // preload all notes into cache
 | ||||||
|  |     await treeCache.getNotes(result.map(r => r.noteId), true); | ||||||
|  | 
 | ||||||
|     $content.empty(); |     $content.empty(); | ||||||
| 
 | 
 | ||||||
|     if (result.length === 0) { |     if (result.length === 0) { | ||||||
| @ -28,7 +33,7 @@ export async function showDialog() { | |||||||
|         const dayEl = $('<div>').append($('<b>').html(utils.formatDate(dateDay))).append(changesListEl); |         const dayEl = $('<div>').append($('<b>').html(utils.formatDate(dateDay))).append(changesListEl); | ||||||
| 
 | 
 | ||||||
|         for (const change of dayChanges) { |         for (const change of dayChanges) { | ||||||
|             const formattedTime = utils.formatTime(utils.parseDate(change.utcDateModifiedTo)); |             const formattedTime = utils.formatTime(utils.parseDate(change.date)); | ||||||
| 
 | 
 | ||||||
|             let noteLink; |             let noteLink; | ||||||
| 
 | 
 | ||||||
| @ -36,7 +41,10 @@ export async function showDialog() { | |||||||
|                 noteLink = change.current_title; |                 noteLink = change.current_title; | ||||||
|             } |             } | ||||||
|             else { |             else { | ||||||
|                 noteLink = await linkService.createNoteLink(change.noteId, change.title); |                 const note = await treeCache.getNote(change.noteId); | ||||||
|  |                 const notePath = await treeService.getSomeNotePath(note); | ||||||
|  | 
 | ||||||
|  |                 noteLink = await linkService.createNoteLinkWithPath(notePath, change.title); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             changesListEl.append($('<li>') |             changesListEl.append($('<li>') | ||||||
| @ -53,7 +61,7 @@ function groupByDate(result) { | |||||||
|     const dayCache = {}; |     const dayCache = {}; | ||||||
| 
 | 
 | ||||||
|     for (const row of result) { |     for (const row of result) { | ||||||
|         let dateDay = utils.parseDate(row.utcDateModifiedTo); |         let dateDay = utils.parseDate(row.date); | ||||||
|         dateDay.setHours(0); |         dateDay.setHours(0); | ||||||
|         dateDay.setMinutes(0); |         dateDay.setMinutes(0); | ||||||
|         dateDay.setSeconds(0); |         dateDay.setSeconds(0); | ||||||
|  | |||||||
| @ -30,8 +30,8 @@ async function createNoteLink(notePath, noteTitle = null) { | |||||||
|     return noteLink; |     return noteLink; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| async function createNoteLinkWithPath(notePath) { | async function createNoteLinkWithPath(notePath, noteTitle = null) { | ||||||
|     const $link = await createNoteLink(notePath); |     const $link = await createNoteLink(notePath, noteTitle); | ||||||
| 
 | 
 | ||||||
|     const $res = $("<span>").append($link); |     const $res = $("<span>").append($link); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -5,17 +5,38 @@ const protectedSessionService = require('../../services/protected_session'); | |||||||
| 
 | 
 | ||||||
| async function getRecentChanges() { | async function getRecentChanges() { | ||||||
|     const recentChanges = await sql.getRows( |     const recentChanges = await sql.getRows( | ||||||
|         `SELECT 
 |         ` | ||||||
|  |         SELECT * FROM ( | ||||||
|  |             SELECT  | ||||||
|  |                 notes.noteId, | ||||||
|                 notes.isDeleted AS current_isDeleted, |                 notes.isDeleted AS current_isDeleted, | ||||||
|                 notes.title AS current_title, |                 notes.title AS current_title, | ||||||
|                 notes.isProtected AS current_isProtected, |                 notes.isProtected AS current_isProtected, | ||||||
|             note_revisions.* |                 note_revisions.title, | ||||||
|  |                 note_revisions.utcDateModifiedTo AS date | ||||||
|             FROM  |             FROM  | ||||||
|                 note_revisions |                 note_revisions | ||||||
|                 JOIN notes USING(noteId) |                 JOIN notes USING(noteId) | ||||||
|             ORDER BY  |             ORDER BY  | ||||||
|                 utcDateModifiedTo DESC |                 utcDateModifiedTo DESC | ||||||
|         LIMIT 1000`);
 |             LIMIT 1000 | ||||||
|  |         ) | ||||||
|  |         UNION ALL SELECT * FROM ( | ||||||
|  |             SELECT | ||||||
|  |                 notes.noteId, | ||||||
|  |                 notes.isDeleted AS current_isDeleted, | ||||||
|  |                 notes.title AS current_title, | ||||||
|  |                 notes.isProtected AS current_isProtected, | ||||||
|  |                 notes.title, | ||||||
|  |                 notes.utcDateCreated AS date | ||||||
|  |             FROM | ||||||
|  |                 notes | ||||||
|  |             ORDER BY | ||||||
|  |                 utcDateCreated DESC | ||||||
|  |             LIMIT 1000 | ||||||
|  |         ) | ||||||
|  |         ORDER BY date DESC  | ||||||
|  |         LIMIT 200`);
 | ||||||
| 
 | 
 | ||||||
|     for (const change of recentChanges) { |     for (const change of recentChanges) { | ||||||
|         if (change.current_isProtected) { |         if (change.current_isProtected) { | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| <div id="recent-changes-dialog" class="modal fade mx-auto" tabindex="-1" role="dialog"> | <div id="recent-changes-dialog" class="modal fade mx-auto" tabindex="-1" role="dialog"> | ||||||
|     <div class="modal-dialog modal-dialog-scrollable" role="document"> |     <div class="modal-dialog modal-lg modal-dialog-scrollable" role="document"> | ||||||
|         <div class="modal-content"> |         <div class="modal-content"> | ||||||
|             <div class="modal-header"> |             <div class="modal-header"> | ||||||
|                 <h5 class="modal-title">Recent changes</h5> |                 <h5 class="modal-title">Recent changes</h5> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam