Skip to content

Commit

Permalink
Improve task subscription for TaskDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatemart committed Mar 3, 2023
1 parent 762d16d commit 8a98fd1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/tasks/TaskDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Paper from '@mui/material/Paper';
import Typography from '@mui/material/Typography';
import { graphql } from 'babel-plugin-relay/macro';
import classNames from 'classnames';
import React, { Suspense, useEffect, useState } from 'react';
import React, { Suspense, useEffect, useState, useMemo } from 'react';
import { useFragment, useMutation, requestSubscription } from 'react-relay';
import { useLocation, useNavigate } from 'react-router-dom';
import { navigateBuildHelper, navigateTaskHelper } from '../../utils/navigateHelper';
Expand Down Expand Up @@ -230,8 +230,9 @@ export default function TaskDetails(props: Props) {
);
let navigate = useNavigate();

const isFinalStatus = useMemo(() => isTaskFinalStatus(task.status), [task.status]);
useEffect(() => {
if (isTaskFinalStatus(task.status)) {
if (isFinalStatus) {
return;
}

Expand All @@ -241,7 +242,7 @@ export default function TaskDetails(props: Props) {
variables: variables,
});
return () => subscription.dispose();
}, [task.id, task.status]);
}, [task.id, isFinalStatus]);

let classes = useStyles();
let build = task.build;
Expand Down

0 comments on commit 8a98fd1

Please sign in to comment.