From b6007a25e85885e96dff6e7972a8f175cfc9738e Mon Sep 17 00:00:00 2001 From: azivner Date: Wed, 6 Sep 2017 21:11:19 -0400 Subject: [PATCH] fix for note duplication in recent notes --- static/js/init.js | 2 +- static/js/note.js | 6 +++--- static/js/tree.js | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/static/js/init.js b/static/js/init.js index 12d4f051f..601f75a38 100644 --- a/static/js/init.js +++ b/static/js/init.js @@ -40,7 +40,7 @@ $(document).bind('keydown', 'alt+q', function() { recentNotesSelectBox.find('option').remove(); // remove the current note - let recNotes = recentNotes.filter(note => note !== globalNote.detail.note_id); + let recNotes = globalRecentNotes.filter(note => note !== globalNote.detail.note_id); $.each(recNotes, function(key, valueNoteId) { let noteTitle = getFullName(valueNoteId); diff --git a/static/js/note.js b/static/js/note.js index 7532d7f9d..e09dd877e 100644 --- a/static/js/note.js +++ b/static/js/note.js @@ -139,7 +139,7 @@ function createNote(node, parentKey, target) { }); } -recentNotes = []; +globalRecentNotes = []; function setNoteBackgroundIfEncrypted(note) { if (note.detail.encryption > 0) { @@ -232,9 +232,9 @@ function addRecentNote(noteTreeId, noteContentId) { // we include the note into recent list only if the user stayed on the note at least 5 seconds if (noteTreeId === globalNote.detail.note_id || noteContentId === globalNote.detail.note_id) { // if it's already there, remove the note - c = recentNotes.filter(note => note !== noteTreeId); + globalRecentNotes = globalRecentNotes.filter(note => note !== noteTreeId); - recentNotes.unshift(noteTreeId); + globalRecentNotes.unshift(noteTreeId); } }, 1500); } diff --git a/static/js/tree.js b/static/js/tree.js index 7679c69b7..48d811d42 100644 --- a/static/js/tree.js +++ b/static/js/tree.js @@ -50,7 +50,7 @@ function deleteNode(node) { globalAllNoteIds = globalAllNoteIds.filter(e => e !== node.key); // remove from recent notes - recentNotes = recentNotes.filter(note => note !== node.key); + globalRecentNotes = globalRecentNotes.filter(note => note !== node.key); let next = node.getNextSibling(); if (!next) {