Sort sections chronologically
This commit is contained in:
parent
88dde1a748
commit
0e33875b3f
@ -38,14 +38,12 @@ export function AllImagesView(vm, params, key, { appbar }) {
|
||||
const date = i.originalDate.substr(0, 10);
|
||||
return Object.assign(acc, { [date]: (acc[date] || []).concat(i) });
|
||||
}, {});
|
||||
const res = Object.entries(sectionMap).reduce(
|
||||
(acc, [date, sectionImages]) =>
|
||||
Object.assign(acc, {
|
||||
[format(date, 'MMMM D, YYYY')]: sectionImages
|
||||
}),
|
||||
{}
|
||||
);
|
||||
return res;
|
||||
return Object.entries(sectionMap)
|
||||
.sort((a, b) => a[0].localeCompare(b[0]))
|
||||
.map(([date, _images]) => ({
|
||||
title: format(date, 'MMMM D, YYYY'),
|
||||
images: _images
|
||||
}));
|
||||
},
|
||||
[images]
|
||||
);
|
||||
@ -163,7 +161,7 @@ export function AllImagesView(vm, params, key, { appbar }) {
|
||||
);
|
||||
});
|
||||
|
||||
function renderSection([title, _images]) {
|
||||
function renderSection({ title, images: _images }) {
|
||||
return AlbumTemplate({
|
||||
title,
|
||||
id: title,
|
||||
@ -185,7 +183,7 @@ export function AllImagesView(vm, params, key, { appbar }) {
|
||||
'.photoOverlay': photoClick
|
||||
}
|
||||
},
|
||||
Object.entries(sections()).map(renderSection)
|
||||
sections().map(renderSection)
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user