mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-02 06:21:50 +01:00
Issue reporter: Improve 'API rate limit' label, fixes #42725
This commit is contained in:
@@ -51,6 +51,7 @@ export class IssueReporter extends Disposable {
|
||||
private environmentService: IEnvironmentService;
|
||||
private telemetryService: ITelemetryService;
|
||||
private issueReporterModel: IssueReporterModel;
|
||||
private shouldQueueSearch = true;
|
||||
|
||||
constructor(configuration: IssueReporterConfiguration) {
|
||||
super();
|
||||
@@ -222,7 +223,7 @@ export class IssueReporter extends Disposable {
|
||||
this.issueReporterModel.update({ issueDescription: (<HTMLInputElement>event.target).value });
|
||||
});
|
||||
|
||||
document.getElementById('issue-title').addEventListener('input', this.searchGitHub);
|
||||
document.getElementById('issue-title').addEventListener('input', (e) => { this.searchGitHub(e); });
|
||||
|
||||
document.getElementById('github-submit-btn').addEventListener('click', () => this.createIssue());
|
||||
|
||||
@@ -259,7 +260,7 @@ export class IssueReporter extends Disposable {
|
||||
}
|
||||
|
||||
@debounce(300)
|
||||
private searchGitHub(event: Event) {
|
||||
private searchGitHub(event: Event): void {
|
||||
const title = (<HTMLInputElement>event.target).value;
|
||||
const similarIssues = document.getElementById('similar-issues');
|
||||
if (title) {
|
||||
@@ -292,25 +293,43 @@ export class IssueReporter extends Disposable {
|
||||
similarIssues.appendChild(message);
|
||||
} else {
|
||||
const message = $('div.list-title');
|
||||
message.textContent = localize('rateLimited', "API rate limit exceeded");
|
||||
message.textContent = localize('rateLimited', "GitHub query limit exceeded. Please wait.");
|
||||
similarIssues.appendChild(message);
|
||||
|
||||
const resetTime = response.headers.get('X-RateLimit-Reset');
|
||||
const timeToWait = parseInt(resetTime) - Math.floor(Date.now() / 1000);
|
||||
if (this.shouldQueueSearch) {
|
||||
this.shouldQueueSearch = false;
|
||||
setTimeout(() => {
|
||||
this.searchGitHub(event);
|
||||
this.shouldQueueSearch = true;
|
||||
}, timeToWait * 1000);
|
||||
}
|
||||
|
||||
throw new Error(result.message);
|
||||
}
|
||||
}).catch((error) => {
|
||||
this.logSearchError(error);
|
||||
});
|
||||
}).catch((error) => {
|
||||
// TODO: Use LogService here.
|
||||
console.log(error);
|
||||
/* __GDPR__
|
||||
"issueReporterSearchError" : {
|
||||
"message" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
|
||||
}
|
||||
*/
|
||||
this.telemetryService.publicLog('issueReporterSearchError', { message: error.message });
|
||||
this.logSearchError(error);
|
||||
});
|
||||
} else {
|
||||
similarIssues.innerHTML = '';
|
||||
}
|
||||
}
|
||||
|
||||
private logSearchError(error: Error) {
|
||||
// TODO: Use LogService here.
|
||||
console.log(error);
|
||||
/* __GDPR__
|
||||
"issueReporterSearchError" : {
|
||||
"message" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
|
||||
}
|
||||
*/
|
||||
this.telemetryService.publicLog('issueReporterSearchError', { message: error.message });
|
||||
}
|
||||
|
||||
private renderBlocks(): void {
|
||||
// Depending on Issue Type, we render different blocks and text
|
||||
const { issueType } = this.issueReporterModel.getData();
|
||||
|
||||
Reference in New Issue
Block a user