diff --git a/package.json b/package.json index 01b4ff41..5b0aa8e9 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,11 @@ "type": "string", "default": "master", "description": "The branch to create pull requests against." + }, + "github.refreshPullRequestStatus": { + "type": "number", + "default": 5, + "description": "Interval in seconds to refresh the current pull request status." } } }, diff --git a/src/status-bar-manager.ts b/src/status-bar-manager.ts index ff723fef..495c4982 100644 --- a/src/status-bar-manager.ts +++ b/src/status-bar-manager.ts @@ -31,10 +31,21 @@ export class StatusBarManager { } private async refreshPullRequestStatus(): Promise { - if (this.githubManager.connected) { - await this.updatePullRequestStatus(); + try { + if (this.githubManager.connected) { + await this.updatePullRequestStatus(); + } + } catch (e) { + if (e instanceof GitHubError) { + console.log(e); + this.channel.appendLine('Failed to update pull request status:'); + this.channel.appendLine(JSON.stringify(e.response, undefined, ' ')); + } else { + throw e; + } } - setTimeout(() => { this.refreshPullRequestStatus(); }, 5000); + setTimeout(() => { this.refreshPullRequestStatus(); }, + vscode.workspace.getConfiguration('github').get('refreshPullRequestStatus', 5) * 1000); } public async updatePullRequestStatus(): Promise {