From 9a4b72606d317f89978ae49286675c7d7c73707a Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 3 Nov 2022 20:28:56 +0200 Subject: [PATCH] Filter "Edited Notes" when hoisted or in a workspace Previously, when the user opened a day note the "Edited Notes" section would indicate all the notes edited in that day, regardless of whether the user was inside a workspace or hoisted a note. Now the "Edited Notes" section filters out the notes if the user has a hoisted note. --- src/routes/api/note_revisions.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/routes/api/note_revisions.js b/src/routes/api/note_revisions.js index 32bb3528d..0d390328c 100644 --- a/src/routes/api/note_revisions.js +++ b/src/routes/api/note_revisions.js @@ -5,6 +5,7 @@ const protectedSessionService = require('../../services/protected_session'); const noteRevisionService = require('../../services/note_revisions'); const utils = require('../../services/utils'); const sql = require('../../services/sql'); +const cls = require('../../services/cls'); const path = require('path'); const becca = require("../../becca/becca"); @@ -124,8 +125,15 @@ function getEditedNotesOnDate(req) { ORDER BY isDeleted LIMIT 50`, {date: req.params.date + '%'}); - const notes = becca.getNotes(noteIds, true) - .map(note => note.getPojo()); + let notes = becca.getNotes(noteIds, true); + + // Narrow down the results if a note is hoisted, similar to "Jump to note". + const hoistedNoteId = cls.getHoistedNoteId(); + if (hoistedNoteId) { + notes = notes.filter(note => note.hasAncestor(hoistedNoteId)); + } + + notes = notes.map(note => note.getPojo()); for (const note of notes) { const notePath = note.isDeleted ? null : beccaService.getNotePath(note.noteId);