diff --git a/src/public/javascripts/dialogs/recent_changes.js b/src/public/javascripts/dialogs/recent_changes.js
index b92e812a6..af2a94bd4 100644
--- a/src/public/javascripts/dialogs/recent_changes.js
+++ b/src/public/javascripts/dialogs/recent_changes.js
@@ -1,6 +1,8 @@
import linkService from '../services/link.js';
import utils from '../services/utils.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 $content = $("#recent-changes-content");
@@ -14,6 +16,9 @@ export async function showDialog() {
const result = await server.get('recent-changes');
+ // preload all notes into cache
+ await treeCache.getNotes(result.map(r => r.noteId), true);
+
$content.empty();
if (result.length === 0) {
@@ -28,7 +33,7 @@ export async function showDialog() {
const dayEl = $('
').append($('
').html(utils.formatDate(dateDay))).append(changesListEl);
for (const change of dayChanges) {
- const formattedTime = utils.formatTime(utils.parseDate(change.utcDateModifiedTo));
+ const formattedTime = utils.formatTime(utils.parseDate(change.date));
let noteLink;
@@ -36,7 +41,10 @@ export async function showDialog() {
noteLink = change.current_title;
}
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($('')
@@ -53,7 +61,7 @@ function groupByDate(result) {
const dayCache = {};
for (const row of result) {
- let dateDay = utils.parseDate(row.utcDateModifiedTo);
+ let dateDay = utils.parseDate(row.date);
dateDay.setHours(0);
dateDay.setMinutes(0);
dateDay.setSeconds(0);
diff --git a/src/public/javascripts/services/link.js b/src/public/javascripts/services/link.js
index 6f4cb77cb..1d66bd27e 100644
--- a/src/public/javascripts/services/link.js
+++ b/src/public/javascripts/services/link.js
@@ -30,8 +30,8 @@ async function createNoteLink(notePath, noteTitle = null) {
return noteLink;
}
-async function createNoteLinkWithPath(notePath) {
- const $link = await createNoteLink(notePath);
+async function createNoteLinkWithPath(notePath, noteTitle = null) {
+ const $link = await createNoteLink(notePath, noteTitle);
const $res = $("").append($link);
diff --git a/src/routes/api/recent_changes.js b/src/routes/api/recent_changes.js
index 4a2075383..162c0a353 100644
--- a/src/routes/api/recent_changes.js
+++ b/src/routes/api/recent_changes.js
@@ -5,17 +5,38 @@ const protectedSessionService = require('../../services/protected_session');
async function getRecentChanges() {
const recentChanges = await sql.getRows(
- `SELECT
- notes.isDeleted AS current_isDeleted,
- notes.title AS current_title,
- notes.isProtected AS current_isProtected,
- note_revisions.*
- FROM
- note_revisions
- JOIN notes USING(noteId)
- ORDER BY
- utcDateModifiedTo DESC
- LIMIT 1000`);
+ `
+ SELECT * FROM (
+ SELECT
+ notes.noteId,
+ notes.isDeleted AS current_isDeleted,
+ notes.title AS current_title,
+ notes.isProtected AS current_isProtected,
+ note_revisions.title,
+ note_revisions.utcDateModifiedTo AS date
+ FROM
+ note_revisions
+ JOIN notes USING(noteId)
+ ORDER BY
+ utcDateModifiedTo DESC
+ 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) {
if (change.current_isProtected) {
diff --git a/src/views/dialogs/recent_changes.ejs b/src/views/dialogs/recent_changes.ejs
index 6e2a3d31f..0fde102b8 100644
--- a/src/views/dialogs/recent_changes.ejs
+++ b/src/views/dialogs/recent_changes.ejs
@@ -1,5 +1,5 @@