@@ -4,7 +4,6 @@ import { escape, template } from 'lodash';
4
4
import SidebarMediator from '~/sidebar/sidebar_mediator' ;
5
5
import glRegexp from './lib/utils/regexp' ;
6
6
import AjaxCache from './lib/utils/ajax_cache' ;
7
- import axios from '~/lib/utils/axios_utils' ;
8
7
import { spriteIcon } from './lib/utils/common_utils' ;
9
8
import * as Emoji from '~/emoji' ;
10
9
@@ -53,15 +52,13 @@ export const defaultAutocompleteConfig = {
53
52
milestones : true ,
54
53
labels : true ,
55
54
snippets : true ,
56
- vulnerabilities : true ,
57
55
} ;
58
56
59
57
class GfmAutoComplete {
60
58
constructor ( dataSources = { } ) {
61
59
this . dataSources = dataSources ;
62
60
this . cachedData = { } ;
63
61
this . isLoadingData = { } ;
64
- this . previousQuery = '' ;
65
62
}
66
63
67
64
setup ( input , enableMap = defaultAutocompleteConfig ) {
@@ -557,7 +554,7 @@ class GfmAutoComplete {
557
554
}
558
555
559
556
getDefaultCallbacks ( ) {
560
- const self = this ;
557
+ const fetchData = this . fetchData . bind ( this ) ;
561
558
562
559
return {
563
560
sorter ( query , items , searchKey ) {
@@ -570,15 +567,7 @@ class GfmAutoComplete {
570
567
} ,
571
568
filter ( query , data , searchKey ) {
572
569
if ( GfmAutoComplete . isLoading ( data ) ) {
573
- self . fetchData ( this . $inputor , this . at ) ;
574
- return data ;
575
- }
576
- if (
577
- GfmAutoComplete . typesWithBackendFiltering . includes ( GfmAutoComplete . atTypeMap [ this . at ] ) &&
578
- self . previousQuery !== query
579
- ) {
580
- self . fetchData ( this . $inputor , this . at , query ) ;
581
- self . previousQuery = query ;
570
+ fetchData ( this . $inputor , this . at ) ;
582
571
return data ;
583
572
}
584
573
return $ . fn . atwho . default . callbacks . filter ( query , data , searchKey ) ;
@@ -626,22 +615,13 @@ class GfmAutoComplete {
626
615
} ;
627
616
}
628
617
629
- fetchData ( $input , at , search ) {
618
+ fetchData ( $input , at ) {
630
619
if ( this . isLoadingData [ at ] ) return ;
631
620
632
621
this . isLoadingData [ at ] = true ;
633
622
const dataSource = this . dataSources [ GfmAutoComplete . atTypeMap [ at ] ] ;
634
623
635
- if ( GfmAutoComplete . typesWithBackendFiltering . includes ( GfmAutoComplete . atTypeMap [ at ] ) ) {
636
- axios
637
- . get ( dataSource , { params : { search } } )
638
- . then ( ( { data } ) => {
639
- this . loadData ( $input , at , data ) ;
640
- } )
641
- . catch ( ( ) => {
642
- this . isLoadingData [ at ] = false ;
643
- } ) ;
644
- } else if ( this . cachedData [ at ] ) {
624
+ if ( this . cachedData [ at ] ) {
645
625
this . loadData ( $input , at , this . cachedData [ at ] ) ;
646
626
} else if ( GfmAutoComplete . atTypeMap [ at ] === 'emojis' ) {
647
627
this . loadEmojiData ( $input , at ) . catch ( ( ) => { } ) ;
@@ -727,8 +707,7 @@ class GfmAutoComplete {
727
707
// https://github.com/ichord/At.js
728
708
const atSymbolsWithBar = Object . keys ( controllers )
729
709
. join ( '|' )
730
- . replace ( / [ $ ] / , '\\$&' )
731
- . replace ( / [ + ] / , '\\+' ) ;
710
+ . replace ( / [ $ ] / , '\\$&' ) ;
732
711
const atSymbolsWithoutBar = Object . keys ( controllers ) . join ( '' ) ;
733
712
const targetSubtext = subtext . split ( GfmAutoComplete . regexSubtext ) . pop ( ) ;
734
713
const resultantFlag = flag . replace ( / [ - [ \] / { } ( ) * + ? . \\ ^ $ | ] / g, '\\$&' ) ;
@@ -759,12 +738,9 @@ GfmAutoComplete.atTypeMap = {
759
738
'~' : 'labels' ,
760
739
'%' : 'milestones' ,
761
740
'/' : 'commands' ,
762
- '+' : 'vulnerabilities' ,
763
741
$ : 'snippets' ,
764
742
} ;
765
743
766
- GfmAutoComplete . typesWithBackendFiltering = [ 'vulnerabilities' ] ;
767
-
768
744
function findEmoji ( name ) {
769
745
return Emoji . searchEmoji ( name , { match : 'contains' , raw : true } ) . sort ( ( a , b ) => {
770
746
if ( a . index !== b . index ) {
0 commit comments