hot fix for task and heaters page erroring when nothing was loaded/undefined

This commit is contained in:
csawatzky 2025-10-14 15:00:31 -06:00
parent f51f98f3ca
commit 3c418343d0
2 changed files with 16 additions and 11 deletions

View file

@ -138,6 +138,7 @@ export default function TaskViewer(props: ViewProps) {
openDialog();
};
const loadMultitask = useCallback(() => {
if (!loadKeys) return;
if (loadKeys.length > 0) {
@ -146,11 +147,13 @@ export default function TaskViewer(props: ViewProps) {
taskAPI
.getMultiTasks(loadKeys, as)
.then(resp => {
resp.data.tasks.forEach(task => {
if (task.settings) {
temp.set(task.key, Task.any(task));
}
});
if(resp.data.tasks){
resp.data.tasks.forEach(task => {
if (task.settings) {
temp.set(task.key, Task.any(task));
}
});
}
setTasks(temp);
setLoaded(true);
})
@ -167,11 +170,13 @@ export default function TaskViewer(props: ViewProps) {
taskAPI
.listTasks(50, 0, "asc", "start", undefined, undefined, as, prevMonth, nextMonth)
.then(resp => {
resp.data.tasks.forEach(task => {
if (task.settings) {
temp.set(task.key, Task.any(task));
}
});
if(resp.data.tasks){
resp.data.tasks.forEach(task => {
if (task.settings) {
temp.set(task.key, Task.any(task));
}
});
}
setTasks(temp);
setLoaded(true);
})