fix(code/frontend): should not polling status if import repo not succeed (#37955) (#38086)

This commit is contained in:
WangQianliang 2019-06-05 23:22:39 +08:00 committed by Mengwei Ding
parent 5c86db3435
commit d04963f700
2 changed files with 6 additions and 8 deletions

View file

@ -28,7 +28,7 @@ export const indexRepoSuccess = createAction<string>('INDEX REPOS SUCCESS');
export const indexRepoFailed = createAction<Error>('INDEX REPOS FAILED');
export const importRepo = createAction<string>('IMPORT REPO');
export const importRepoSuccess = createAction<string>('IMPORT REPO SUCCESS');
export const importRepoSuccess = createAction<Repository>('IMPORT REPO SUCCESS');
export const importRepoFailed = createAction<Error>('IMPORT REPO FAILED');
export const closeToast = createAction('CLOSE TOAST');

View file

@ -21,14 +21,12 @@ import {
takeLatest,
} from 'redux-saga/effects';
import { RepositoryUtils } from '../../common/repository_utils';
import { Repository, RepositoryUri, WorkerReservedProgress } from '../../model';
import * as ROUTES from '../components/routes';
import { allStatusSelector, repoUriSelector, routeSelector } from '../selectors';
import {
deleteRepo,
fetchReposSuccess,
importRepo,
indexRepo,
loadRepoSuccess,
loadStatusFailed,
@ -43,6 +41,7 @@ import {
pollRepoCloneStatusStop,
pollRepoDeleteStatusStop,
pollRepoIndexStatusStop,
importRepoSuccess,
} from '../actions';
import { RepoState } from '../reducers';
import {
@ -170,9 +169,8 @@ export function* watchResetPollingStatus() {
}
const parseCloneStatusPollingRequest = (action: Action<any>) => {
if (action.type === String(importRepo)) {
const repoUrl: string = action.payload;
return RepositoryUtils.buildRepository(repoUrl).uri;
if (action.type === String(importRepoSuccess)) {
return action.payload.uri;
} else if (action.type === String(pollRepoCloneStatusStart)) {
return action.payload;
}
@ -213,7 +211,7 @@ export function* watchRepoCloneStatusPolling() {
// * user click import repository
// * repository status has been loaded and it's in cloning
yield takeEvery(
[String(importRepo), String(pollRepoCloneStatusStart)],
[String(importRepoSuccess), String(pollRepoCloneStatusStart)],
pollRepoCloneStatusRunner
);
}
@ -346,7 +344,7 @@ function createRepoStatusPollingRunner(
// Wait for the cancellation task
yield take(pollingStopActionFunctionPattern(repoUri));
// Cancell the task
// Cancel the task
yield cancel(task);
};
}