onthisday: fix on year boundaries (fix #333)
parent
62ae3c910a
commit
c6ef65f69a
|
@ -124,20 +124,27 @@ export default defineComponent({
|
||||||
this.years = [];
|
this.years = [];
|
||||||
|
|
||||||
let currentYear = 9999;
|
let currentYear = 9999;
|
||||||
|
let currentText = "";
|
||||||
|
|
||||||
for (const photo of photos) {
|
for (const photo of photos) {
|
||||||
const dateTaken = utils.dayIdToDate(photo.dayid);
|
const dateTaken = utils.dayIdToDate(photo.dayid);
|
||||||
const year = dateTaken.getUTCFullYear();
|
const year = dateTaken.getUTCFullYear();
|
||||||
photo.key = `${photo.fileid}`;
|
photo.key = `${photo.fileid}`;
|
||||||
|
|
||||||
|
// DateTime calls are expensive, so check if the year
|
||||||
|
// itself is different first, then also check the text
|
||||||
if (year !== currentYear) {
|
if (year !== currentYear) {
|
||||||
|
const text = utils.getFromNowStr(dateTaken);
|
||||||
|
if (text !== currentText) {
|
||||||
this.years.push({
|
this.years.push({
|
||||||
year,
|
year,
|
||||||
|
text,
|
||||||
url: "",
|
url: "",
|
||||||
preview: null,
|
preview: null,
|
||||||
photos: [],
|
photos: [],
|
||||||
text: utils.getFromNowStr(dateTaken),
|
|
||||||
});
|
});
|
||||||
|
currentText = text;
|
||||||
|
}
|
||||||
currentYear = year;
|
currentYear = year;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue