fix for tasks being undefined when none were loaded

This commit is contained in:
csawatzky 2025-10-14 14:58:09 -06:00
parent 4bf8a5d2ff
commit ea94fab0a5

View file

@ -154,15 +154,18 @@ export default function TaskViewer(props: ViewProps) {
taskAPI taskAPI
.listTasks(50, 0, "asc", "start", undefined, undefined, as, prevMonth, nextMonth) .listTasks(50, 0, "asc", "start", undefined, undefined, as, prevMonth, nextMonth)
.then(resp => { .then(resp => {
resp.data.tasks.forEach(task => { if(resp.data.tasks){
if (task.settings) { resp.data.tasks.forEach(task => {
temp.set(task.key, Task.any(task)); if (task.settings) {
} temp.set(task.key, Task.any(task));
}); }
});
}
setTasks(temp); setTasks(temp);
setLoaded(true); setLoaded(true);
}) })
.catch(err => { .catch(err => {
console.log(err)
openSnack("Failed to load tasks"); openSnack("Failed to load tasks");
}); });
}, [taskAPI, as, user, openSnack, nextMonth, prevMonth]); }, [taskAPI, as, user, openSnack, nextMonth, prevMonth]);