Updates polling function to guarantee we won't make a request while polling
This commit is contained in:
parent
6f9fdebc0e
commit
90fc9237c2
1 changed files with 16 additions and 7 deletions
|
@ -49,6 +49,7 @@ export default {
|
||||||
pagenum: 1,
|
pagenum: 1,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
hasError: false,
|
hasError: false,
|
||||||
|
isMakingRequest: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -136,6 +137,7 @@ export default {
|
||||||
data: { page: pageNumber, scope },
|
data: { page: pageNumber, scope },
|
||||||
successCallback: this.successCallback,
|
successCallback: this.successCallback,
|
||||||
errorCallback: this.errorCallback,
|
errorCallback: this.errorCallback,
|
||||||
|
notificationCallback: this.setIsMakingRequest,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!Visibility.hidden()) {
|
if (!Visibility.hidden()) {
|
||||||
|
@ -143,8 +145,8 @@ export default {
|
||||||
poll.makeRequest();
|
poll.makeRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
Visibility.change((e, state) => {
|
Visibility.change(() => {
|
||||||
if (state === 'visible') {
|
if (!Visibility.hidden()) {
|
||||||
poll.restart();
|
poll.restart();
|
||||||
} else {
|
} else {
|
||||||
poll.stop();
|
poll.stop();
|
||||||
|
@ -155,7 +157,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeUpdate() {
|
beforeUpdate() {
|
||||||
if (this.state.pipelines.length && this.$children) {
|
if (this.state.pipelines.length && this.$children && !this.isMakingRequest) {
|
||||||
this.store.startTimeAgoLoops.call(this, Vue);
|
this.store.startTimeAgoLoops.call(this, Vue);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -181,10 +183,13 @@ export default {
|
||||||
const pageNumber = gl.utils.getParameterByName('page') || this.pagenum;
|
const pageNumber = gl.utils.getParameterByName('page') || this.pagenum;
|
||||||
const scope = gl.utils.getParameterByName('scope') || this.apiScope;
|
const scope = gl.utils.getParameterByName('scope') || this.apiScope;
|
||||||
|
|
||||||
this.isLoading = true;
|
if (!this.isMakingRequest) {
|
||||||
return this.service.getPipelines({ scope, page: pageNumber })
|
this.isLoading = true;
|
||||||
.then(response => this.successCallback(response))
|
|
||||||
.catch(() => this.errorCallback());
|
this.service.getPipelines({ scope, page: pageNumber })
|
||||||
|
.then(response => this.successCallback(response))
|
||||||
|
.catch(() => this.errorCallback());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
successCallback(resp) {
|
successCallback(resp) {
|
||||||
|
@ -204,6 +209,10 @@ export default {
|
||||||
this.hasError = true;
|
this.hasError = true;
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
setIsMakingRequest(isMakingRequest) {
|
||||||
|
this.isMakingRequest = isMakingRequest;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
template: `
|
template: `
|
||||||
|
|
Loading…
Reference in a new issue