@@ -66,9 +66,7 @@ export class IssueReporter extends Disposable {
6666 private telemetryService : ITelemetryService ;
6767 private logService : ILogService ;
6868 private issueReporterModel : IssueReporterModel ;
69- private shouldQueueSearch = true ;
7069 private numberOfSearchResultsDisplayed = 0 ;
71- private features : IssueReporterFeatures ;
7270 private receivedSystemInfo = false ;
7371 private receivedPerformanceInfo = false ;
7472
@@ -86,8 +84,6 @@ export class IssueReporter extends Disposable {
8684 extensionsDisabled : this . environmentService . disableExtensions ,
8785 } ) ;
8886
89- this . features = configuration . features ;
90-
9187 ipcRenderer . on ( 'issuePerformanceInfoResponse' , ( event , info ) => {
9288 this . logService . trace ( 'issueReporter: Received performance data' ) ;
9389 this . issueReporterModel . update ( info ) ;
@@ -338,13 +334,23 @@ export class IssueReporter extends Disposable {
338334 const issueDescription = ( < HTMLInputElement > event . target ) . value ;
339335 this . issueReporterModel . update ( { issueDescription } ) ;
340336
341- if ( this . features . useDuplicateSearch ) {
342- const title = ( < HTMLInputElement > document . getElementById ( 'issue-title' ) ) . value ;
337+ const title = ( < HTMLInputElement > document . getElementById ( 'issue-title' ) ) . value ;
338+ if ( title || issueDescription ) {
343339 this . searchDuplicates ( title , issueDescription ) ;
340+ } else {
341+ this . clearSearchResults ( ) ;
344342 }
345343 } ) ;
346344
347- document . getElementById ( 'issue-title' ) . addEventListener ( 'input' , ( e ) => { this . searchIssues ( e ) ; } ) ;
345+ document . getElementById ( 'issue-title' ) . addEventListener ( 'input' , ( e ) => {
346+ const description = this . issueReporterModel . getData ( ) . issueDescription ;
347+ const title = ( < HTMLInputElement > event . target ) . value ;
348+ if ( title || description ) {
349+ this . searchDuplicates ( title , description ) ;
350+ } else {
351+ this . clearSearchResults ( ) ;
352+ }
353+ } ) ;
348354
349355 document . getElementById ( 'github-submit-btn' ) . addEventListener ( 'click' , ( ) => this . createIssue ( ) ) ;
350356
@@ -427,21 +433,6 @@ export class IssueReporter extends Disposable {
427433 return false ;
428434 }
429435
430- @debounce ( 300 )
431- private searchIssues ( event : Event ) : void {
432- const title = ( < HTMLInputElement > event . target ) . value ;
433- if ( title ) {
434- if ( this . features . useDuplicateSearch ) {
435- const description = this . issueReporterModel . getData ( ) . issueDescription ;
436- this . searchDuplicates ( title , description ) ;
437- } else {
438- this . searchGitHub ( title ) ;
439- }
440- } else {
441- this . clearSearchResults ( ) ;
442- }
443- }
444-
445436 private clearSearchResults ( ) : void {
446437 const similarIssues = document . getElementById ( 'similar-issues' ) ;
447438 similarIssues . innerHTML = '' ;
@@ -479,53 +470,17 @@ export class IssueReporter extends Disposable {
479470 } ) ;
480471 }
481472
482- private searchGitHub ( title : string ) : void {
483- const query = `is:issue+repo:microsoft/vscode+${ title } ` ;
484- const similarIssues = document . getElementById ( 'similar-issues' ) ;
485-
486- window . fetch ( `https://api.github.com/search/issues?q=${ query } ` ) . then ( ( response ) => {
487- response . json ( ) . then ( result => {
488- similarIssues . innerHTML = '' ;
489- if ( result && result . items ) {
490- this . displaySearchResults ( result . items ) ;
491- } else {
492- // If the items property isn't present, the rate limit has been hit
493- const message = $ ( 'div.list-title' ) ;
494- message . textContent = localize ( 'rateLimited' , "GitHub query limit exceeded. Please wait." ) ;
495- similarIssues . appendChild ( message ) ;
496-
497- const resetTime = response . headers . get ( 'X-RateLimit-Reset' ) ;
498- const timeToWait = parseInt ( resetTime ) - Math . floor ( Date . now ( ) / 1000 ) ;
499- if ( this . shouldQueueSearch ) {
500- this . shouldQueueSearch = false ;
501- setTimeout ( ( ) => {
502- this . searchGitHub ( title ) ;
503- this . shouldQueueSearch = true ;
504- } , timeToWait * 1000 ) ;
505- }
506-
507- throw new Error ( result . message ) ;
508- }
509- } ) . catch ( ( error ) => {
510- this . logSearchError ( error ) ;
511- } ) ;
512- } ) . catch ( ( error ) => {
513- this . logSearchError ( error ) ;
514- } ) ;
515- }
516-
517473 private displaySearchResults ( results : SearchResult [ ] ) {
518474 const similarIssues = document . getElementById ( 'similar-issues' ) ;
519475 if ( results . length ) {
520- const hasIssueState = results . every ( result => ! ! result . state ) ;
521- const issues = hasIssueState ? $ ( 'div.issues-container' ) : $ ( 'ul.issues-container' ) ;
476+ const issues = $ ( 'div.issues-container' ) ;
522477 const issuesText = $ ( 'div.list-title' ) ;
523478 issuesText . textContent = localize ( 'similarIssues' , "Similar issues" ) ;
524479
525480 this . numberOfSearchResultsDisplayed = results . length < 5 ? results . length : 5 ;
526481 for ( let i = 0 ; i < this . numberOfSearchResultsDisplayed ; i ++ ) {
527482 const issue = results [ i ] ;
528- const link = issue . state ? $ ( 'a.issue-link' , { href : issue . html_url } ) : $ ( 'a ', { href : issue . html_url } ) ;
483+ const link = $ ( 'a.issue-link' , { href : issue . html_url } ) ;
529484 link . textContent = issue . title ;
530485 link . title = issue . title ;
531486 link . addEventListener ( 'click' , ( e ) => this . openLink ( e ) ) ;
@@ -547,7 +502,7 @@ export class IssueReporter extends Disposable {
547502 issueState . appendChild ( issueStateLabel ) ;
548503 }
549504
550- const item = issue . state ? $ ( 'div.issue' , { } , issueState , link ) : $ ( 'li.issue' , { } , link ) ;
505+ const item = $ ( 'div.issue' , { } , issueState , link ) ;
551506 issues . appendChild ( item ) ;
552507 }
553508
@@ -806,11 +761,9 @@ export class IssueReporter extends Disposable {
806761 shell . openExternal ( ( < HTMLAnchorElement > event . target ) . href ) ;
807762
808763 /* __GDPR__
809- "issueReporterViewSimilarIssue" : {
810- "usingDuplicatesAPI" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
811- }
764+ "issueReporterViewSimilarIssue" : { }
812765 */
813- this . telemetryService . publicLog ( 'issueReporterViewSimilarIssue' , { usingDuplicatesAPI : this . features . useDuplicateSearch } ) ;
766+ this . telemetryService . publicLog ( 'issueReporterViewSimilarIssue' ) ;
814767 }
815768 }
816769}
0 commit comments