Refactor error handling in Global Status component to prevent duplicate entries in errorRepositories
testing/ogGui-multibranch/pipeline/head This commit looks good
Details
testing/ogGui-multibranch/pipeline/head This commit looks good
Details
parent
081da1efc6
commit
11a4773570
|
|
@ -106,25 +106,27 @@ export class GlobalStatusComponent implements OnInit {
|
||||||
const timeoutId = setTimeout(() => {
|
const timeoutId = setTimeout(() => {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.repositories.forEach(repository => {
|
this.repositories.forEach(repository => {
|
||||||
this.errorRepositories[repository.uuid] = true;
|
if (!(repository.uuid in this.errorRepositories)) {
|
||||||
|
this.errorRepositories[repository.uuid] = true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}, 5000);
|
}, 5000);
|
||||||
|
|
||||||
this.http.get<any>(`${this.repositoriesUrl}?page=1&itemsPerPage=10`).subscribe(
|
this.http.get<any>(`${this.repositoriesUrl}?page=1&itemsPerPage=10`).subscribe(
|
||||||
data => {
|
data => {
|
||||||
this.repositories = data['hydra:member'];
|
this.repositories = data['hydra:member'];
|
||||||
let remainingRepositories = this.repositories.length;
|
let remainingRepositories = this.repositories.length;
|
||||||
|
|
||||||
this.repositories.forEach(repository => {
|
this.repositories.forEach(repository => {
|
||||||
this.loadRepositoryStatus(repository.uuid, (errorOccurred: boolean) => {
|
this.loadRepositoryStatus(repository.uuid, (errorOccurred: boolean) => {
|
||||||
remainingRepositories--;
|
remainingRepositories--;
|
||||||
|
|
||||||
|
this.errorRepositories[repository.uuid] = errorOccurred;
|
||||||
|
|
||||||
if (remainingRepositories === 0) {
|
if (remainingRepositories === 0) {
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
clearTimeout(timeoutId);
|
clearTimeout(timeoutId);
|
||||||
}
|
}
|
||||||
if (errorOccurred) {
|
|
||||||
this.errorRepositories[repository.uuid] = true;
|
|
||||||
} else {
|
|
||||||
this.errorRepositories[repository.uuid] = false;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue