Fix functions crossreference

This commit is contained in:
Nikita Nek Dudnik
2020-05-18 14:14:03 +02:00
parent 2d5787214a
commit 44389c61b8
4 changed files with 16 additions and 19 deletions
@@ -33,5 +33,5 @@ export const useAsyncPolling = (
const stopPolling = () => {
isPolling.current = false;
};
return { isPolling, startPolling, stopPolling };
return { startPolling, stopPolling };
};
@@ -29,11 +29,6 @@ export function useBuildWithSteps(buildId: number) {
const api = useApi(circleCIApiRef);
const errorApi = useApi(errorApiRef);
const { isPolling, startPolling, stopPolling } = useAsyncPolling(
() => getBuildWithSteps(),
INTERVAL_AMOUNT,
);
const getBuildWithSteps = async () => {
try {
const options = {
@@ -45,12 +40,17 @@ export function useBuildWithSteps(buildId: number) {
},
};
const build = await api.getBuild(buildId, options);
if (isPolling) dispatch({ type: 'setBuildWithSteps', payload: build });
dispatch({ type: 'setBuildWithSteps', payload: build });
} catch (e) {
errorApi.post(e);
}
};
const { startPolling, stopPolling } = useAsyncPolling(
getBuildWithSteps,
INTERVAL_AMOUNT,
);
const restartBuild = async () => {
try {
await api.retry(buildId, {
+9 -9
View File
@@ -27,10 +27,6 @@ export function useBuilds() {
const api = useApi(circleCIApiRef);
const errorApi = useApi(errorApiRef);
const { isPolling, startPolling, stopPolling } = useAsyncPolling(
() => getBuilds(),
INTERVAL_AMOUNT,
);
const getBuilds = async () => {
if (settings.owner === '' || settings.repo === '') return;
@@ -43,16 +39,20 @@ export function useBuilds() {
type: GitType.GITHUB,
},
});
if (isPolling)
dispatch({
type: 'setBuilds',
payload: newBuilds,
});
dispatch({
type: 'setBuilds',
payload: newBuilds,
});
} catch (e) {
errorApi.post(e);
}
};
const { startPolling, stopPolling } = useAsyncPolling(
getBuilds,
INTERVAL_AMOUNT,
);
const restartBuild = async (buildId: number) => {
try {
await api.retry(buildId, {