From ee07d2d2d88d109977dbfc55b4e341f294973754 Mon Sep 17 00:00:00 2001 From: azivner Date: Sat, 4 Nov 2017 11:32:05 -0400 Subject: [PATCH] fixes in recent changes and handling encrypted notes --- public/javascripts/recent_changes.js | 135 ++++++++++++++------------- public/javascripts/recent_notes.js | 8 +- public/javascripts/tree_utils.js | 10 +- 3 files changed, 81 insertions(+), 72 deletions(-) diff --git a/public/javascripts/recent_changes.js b/public/javascripts/recent_changes.js index 540355c3d..246e10d60 100644 --- a/public/javascripts/recent_changes.js +++ b/public/javascripts/recent_changes.js @@ -1,83 +1,86 @@ -function showRecentChanges() { - $("#recent-changes-dialog").dialog({ +const recentChangesDialog = $("#recent-changes-dialog"); + +async function showRecentChanges() { + recentChangesDialog.dialog({ modal: true, width: 800, height: 700 }); - $.ajax({ + const result = await $.ajax({ url: baseApiUrl + 'recent-changes/', type: 'GET', - success: result => { - const groupedByDate = new Map(); - const dayCache = {}; - - for (const row of result) { - if (row.encryption > 0 && !isEncryptionAvailable()) { - row.note_title = "[encrypted]"; - } - else { - row.note_title = getFullName(row.note_id); - } - - - let dateDay = getDateFromTS(row.date_modified_to); - dateDay.setHours(0); - dateDay.setMinutes(0); - dateDay.setSeconds(0); - dateDay.setMilliseconds(0); - - // this stupidity is to make sure that we always use the same day object because Map uses only - // reference equality - if (dayCache[dateDay]) { - dateDay = dayCache[dateDay]; - } - else { - dayCache[dateDay] = dateDay; - } - - if (!groupedByDate.has(dateDay)) { - groupedByDate.set(dateDay, []); - } - - groupedByDate.get(dateDay).push(row); - } - - for (const [dateDay, dayChanges] of groupedByDate) { - const changesListEl = $('