Skip to content

Commit

Permalink
chore(frontend): refresh task status in TaskView.js (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
shini4i authored Jan 23, 2024
1 parent 910baac commit 4aa6228
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions web/src/Components/TaskView.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,30 @@ export default function TaskView() {
});
}, [id]);

useEffect(() => {
let intervalId;

const fetchTaskStatus = async () => {
console.log('Fetching task status...')
try {
const updatedTask = await fetchTask(id);
setTask(updatedTask);
} catch (error) {
setError('fetchTaskStatus', error.message);
}
};

if (task && task.status === 'in progress') {
intervalId = setInterval(fetchTaskStatus, 10000);
}

return () => {
if (intervalId) {
clearInterval(intervalId);
}
};
}, [task]);

const userIsPrivileged = groups && privilegedGroups && groups.some(group => privilegedGroups.includes(group));

const rollbackToVersion = async () => {
Expand Down

0 comments on commit 4aa6228

Please sign in to comment.