|
201 | 201 | fetchMergeRequestsDetailsThenUpdateUI(mergeRequestIds) { |
202 | 202 | let self = this; |
203 | 203 |
|
204 | | - this.apiClient.getProjectMergeRequests( |
205 | | - this.currentProjectId, |
206 | | - mergeRequestIds |
207 | | - ).then(function(responseData) { |
| 204 | + this.fetchMergeRequestsDetails(mergeRequestIds).then(function(responseData) { |
208 | 205 | if (self.preferences.display_source_and_target_branches) { |
209 | 206 | self.removeExistingTargetBranchNodes(); |
210 | 207 | } |
|
224 | 221 | } |
225 | 222 |
|
226 | 223 | if (self.preferences.automatically_update_pipeline_status_icons) { |
227 | | - setTimeout(function() { |
228 | | - // TODO Set timeout to call Gitlab API again and update icons |
229 | | - }, 10000); |
| 224 | + self.schedulePipelineStatusIconsUpdate(); |
230 | 225 | } |
231 | 226 | }); |
232 | 227 | } |
233 | 228 |
|
| 229 | + /** |
| 230 | + * Performs an HTTP GET request to the GitLab API to retrieve details about Merge Requests that are |
| 231 | + * currently displayed. |
| 232 | + */ |
| 233 | + fetchMergeRequestsDetails(mergeRequestIds) { |
| 234 | + return this.apiClient.getProjectMergeRequests( |
| 235 | + this.currentProjectId, |
| 236 | + mergeRequestIds |
| 237 | + ); |
| 238 | + } |
| 239 | + |
234 | 240 | /** |
235 | 241 | * Removes all branches that may have been already displayed by GitLab. |
236 | 242 | */ |
|
572 | 578 | return placeholders[placeholder]; |
573 | 579 | }).trim(); |
574 | 580 | } |
| 581 | + |
| 582 | + /* |
| 583 | + * Schedule a pipeline status icons update to be performed in 10 seconds. |
| 584 | + */ |
| 585 | + schedulePipelineStatusIconsUpdate() { |
| 586 | + let self = this; |
| 587 | + |
| 588 | + setTimeout(function() { |
| 589 | + self.updatePipelineStatusIcons(); |
| 590 | + }, 10000); |
| 591 | + } |
| 592 | + |
| 593 | + /** |
| 594 | + * Actually update pipeline status icons by invoking the GitLab API. |
| 595 | + */ |
| 596 | + updatePipelineStatusIcons() { |
| 597 | + let self = this; |
| 598 | + |
| 599 | + this.fetchMergeRequestsDetails(mergeRequestIds).then(function(responseData) { |
| 600 | + // TODO actually update icons |
| 601 | + |
| 602 | + self.schedulePipelineStatusIconsUpdate(); |
| 603 | + }); |
| 604 | + } |
575 | 605 | } |
576 | 606 |
|
577 | 607 | let cs = new ContentScript(); |
|
0 commit comments