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
- recent changes - link to note should lead to the revision
- 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:
- modularize frontend
@ -22,6 +28,7 @@ Encryption:
Bugs:
- 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'
- recent changes sorts 1st october to the end
Others:
- 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 formattedDate = formatDate(dateModified);
const dateDay = getDateFromTS(row.date_modified);
dateDay.setHours(0);
dateDay.setMinutes(0);
dateDay.setSeconds(0);
dateDay.setMilliseconds(0);
if (!groupedByDate[formattedDate]) {
groupedByDate[formattedDate] = [];
const dateDayTS = dateDay.getTime(); // we can't use dateDay as key because complex objects can't be keys
if (!groupedByDate[dateDayTS]) {
groupedByDate[dateDayTS] = [];
}
groupedByDate[formattedDate].push(row);
groupedByDate[dateDayTS].push(row);
}
const sortedDates = Object.keys(groupedByDate);
sortedDates.sort();
sortedDates.reverse();
for (const formattedDay of sortedDates) {
for (const dateDayTS of sortedDates) {
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 noteLink = $("<a>", {