mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
fix preening when history entries are null
This commit is contained in:
@@ -41,6 +41,7 @@ export function preenHistory (history, isSubscribed, timezoneOffset = 0, dayStar
|
|||||||
|
|
||||||
// Keep uncompressed entries (modifies history and returns removed items)
|
// Keep uncompressed entries (modifies history and returns removed items)
|
||||||
let newHistory = _.remove(history, entry => {
|
let newHistory = _.remove(history, entry => {
|
||||||
|
if (!entry) return true; // sometimes entries are `null`
|
||||||
const entryDate = moment(entry.date).zone(timezoneOffset);
|
const entryDate = moment(entry.date).zone(timezoneOffset);
|
||||||
if (entryDate.hour() < dayStart) entryDate.subtract(1, 'day');
|
if (entryDate.hour() < dayStart) entryDate.subtract(1, 'day');
|
||||||
return entryDate.isSame(cutOff) || entryDate.isAfter(cutOff);
|
return entryDate.isSame(cutOff) || entryDate.isAfter(cutOff);
|
||||||
@@ -49,6 +50,7 @@ export function preenHistory (history, isSubscribed, timezoneOffset = 0, dayStar
|
|||||||
// Date after which to begin compressing data by year
|
// Date after which to begin compressing data by year
|
||||||
let monthsCutOff = cutOff.subtract(isSubscribed ? 12 : 10, 'months').startOf('day');
|
let monthsCutOff = cutOff.subtract(isSubscribed ? 12 : 10, 'months').startOf('day');
|
||||||
let aggregateByMonth = _.remove(history, entry => {
|
let aggregateByMonth = _.remove(history, entry => {
|
||||||
|
if (!entry) return true; // sometimes entries are `null`
|
||||||
const entryDate = moment(entry.date).zone(timezoneOffset);
|
const entryDate = moment(entry.date).zone(timezoneOffset);
|
||||||
if (entryDate.hour() < dayStart) entryDate.subtract(1, 'day');
|
if (entryDate.hour() < dayStart) entryDate.subtract(1, 'day');
|
||||||
return entryDate.isSame(monthsCutOff) || entryDate.isAfter(monthsCutOff);
|
return entryDate.isSame(monthsCutOff) || entryDate.isAfter(monthsCutOff);
|
||||||
|
|||||||
Reference in New Issue
Block a user