Fix issue with crashing when having no entries today
This commit is contained in:
@@ -34,9 +34,10 @@
|
|||||||
remainingToday = $settingsStore.target;
|
remainingToday = $settingsStore.target;
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
let todayDate = formatter.format(now);
|
let todayDate = formatter.format(now);
|
||||||
const [day, month, year] = todayDate.split('/');
|
const [day, month, year] = todayDate.split("/");
|
||||||
todayDate = `${year}-${month}-${day}`;
|
todayDate = `${year}-${month}-${day}`;
|
||||||
|
|
||||||
|
if ($foodStore) {
|
||||||
$foodStore.forEach((food) => {
|
$foodStore.forEach((food) => {
|
||||||
if (food.date.split("T")[0] == todayDate) {
|
if (food.date.split("T")[0] == todayDate) {
|
||||||
remainingToday -= food.energy;
|
remainingToday -= food.energy;
|
||||||
@@ -44,6 +45,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
remainingToday = Math.round(remainingToday);
|
remainingToday = Math.round(remainingToday);
|
||||||
computeColor();
|
computeColor();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user