fixed sorting of recent changes

This commit is contained in:
azivner 2017-10-01 22:47:41 -04:00
parent bd7be9a8fd
commit 5d4c06a229
2 changed files with 22 additions and 8 deletions

7
TODO
View File

@ -6,6 +6,12 @@ New features:
deterministic to allow lookup by cipher text deterministic to allow lookup by cipher text
- recent changes - link to note should lead to the revision - recent changes - link to note should lead to the revision
- db upgrade / migration - db upgrade / migration
- db backup into directory
- recent notes can either go to or add link
- might do the same thing with alt-j and alt-l
- ctrl-b nad linkem by mohlo byt goto do notu
- potencialne nova navigace back - forward
- javascript editor
Refactorings: Refactorings:
- modularize frontend - modularize frontend
@ -22,6 +28,7 @@ Encryption:
Bugs: Bugs:
- deleting cloned nodes ends with 500 (probably only on folders) - deleting cloned nodes ends with 500 (probably only on folders)
- Uncaught Error: cannot call methods on fancytree prior to initialization; attempted to call method 'getTree' - Uncaught Error: cannot call methods on fancytree prior to initialization; attempted to call method 'getTree'
- recent changes sorts 1st october to the end
Others: Others:
- dates should be stored in UTC to work correctly with time zones - dates should be stored in UTC to work correctly with time zones

View File

@ -21,26 +21,33 @@ $(document).bind('keydown', 'alt+r', function() {
} }
} }
const dateModified = getDateFromTS(row.date_modified); const dateDay = getDateFromTS(row.date_modified);
const formattedDate = formatDate(dateModified); dateDay.setHours(0);
dateDay.setMinutes(0);
dateDay.setSeconds(0);
dateDay.setMilliseconds(0);
if (!groupedByDate[formattedDate]) { const dateDayTS = dateDay.getTime(); // we can't use dateDay as key because complex objects can't be keys
groupedByDate[formattedDate] = [];
if (!groupedByDate[dateDayTS]) {
groupedByDate[dateDayTS] = [];
} }
groupedByDate[formattedDate].push(row); groupedByDate[dateDayTS].push(row);
} }
const sortedDates = Object.keys(groupedByDate); const sortedDates = Object.keys(groupedByDate);
sortedDates.sort(); sortedDates.sort();
sortedDates.reverse(); sortedDates.reverse();
for (const formattedDay of sortedDates) { for (const dateDayTS of sortedDates) {
const changesListEl = $('<ul>'); const changesListEl = $('<ul>');
const dayEl = $('<div>').append($('<b>').html(formattedDay)).append(changesListEl); const formattedDate = formatDate(getDateFromTS(groupedByDate[dateDayTS][0].date_modified));
for (const dayChanges of groupedByDate[formattedDay]) { const dayEl = $('<div>').append($('<b>').html(formattedDate)).append(changesListEl);
for (const dayChanges of groupedByDate[dateDayTS]) {
const formattedTime = formatTime(getDateFromTS(dayChanges.date_modified)); const formattedTime = formatTime(getDateFromTS(dayChanges.date_modified));
const noteLink = $("<a>", { const noteLink = $("<a>", {