Skip to content

Build your personal knowledge base with Trilium Notes

adding notes to recent list only after some time period (currently 1500ms)

azivner8a928f05f352
diff --git a/static/js/init.js b/static/js/init.js
index ffc90ec439..91d37e0f9a 100644
--- a/static/js/init.js
+++ b/static/js/init.js
@@ -26,7 +26,7 @@ $(document).bind('keypress', 'alt+q', function() {
recentNotesSelectBox.find('option').remove();
// remove the current note
- let recNotes = recentNotes.slice(1);
+ let recNotes = recentNotes.filter(note => note.noteId !== globalNote.detail.note_id);
$.each(recNotes, function(key, value) {
let option = $("<option></option>")
diff --git a/static/js/note.js b/static/js/note.js
index 0a03b89a0a..26c2a11289 100644
--- a/static/js/note.js
+++ b/static/js/note.js
@@ -170,13 +170,22 @@ function loadNote(noteId) {
}
function addRecentNote(noteId, noteTitle) {
- // if it's already there, remove the note
- recentNotes = recentNotes.filter(note => note.noteId !== noteId);
+ const origDate = new Date();
- recentNotes.unshift({
- noteId: noteId,
- noteTitle: noteTitle
- });
+ setTimeout(function() {
+ // we include the note into recent list only if the user stayed on the note at least 5 seconds
+ if (noteId === globalNote.detail.note_id) {
+ // if it's already there, remove the note
+ recentNotes = recentNotes.filter(note => note.noteId !== noteId);
+
+ // console.log("added after " + (new Date().getTime() - origDate.getTime()));
+
+ recentNotes.unshift({
+ noteId: noteId,
+ noteTitle: noteTitle
+ });
+ }
+ }, 1500);
}
function encryptNote() {