@@ -23,7 +23,7 @@ class UserService {
23
23
let validEmails = [ ] ;
24
24
emails . forEach ( email => {
25
25
this . waitingExecCallbacks . push ( callback ) ;
26
- if ( this . emailUserMap [ email ] || this . waitingQueryEmails . includes ( email ) ) return ;
26
+ if ( ! email || this . emailUserMap [ email ] || this . waitingQueryEmails . includes ( email ) ) return ;
27
27
validEmails . push ( email ) ;
28
28
} ) ;
29
29
if ( validEmails . length === 0 ) return ;
@@ -32,24 +32,26 @@ class UserService {
32
32
} ;
33
33
34
34
startQueryUsers = ( ) => {
35
- if ( this . pendingTimer || this . waitingQueryEmails . length === 0 ) return ;
35
+ if ( this . pendingTimer ) return ;
36
36
this . pendingTimer = setTimeout ( ( ) => {
37
- this . api ( this . waitingQueryEmails ) . then ( res => {
38
- const { user_list } = res . data ;
39
- user_list . forEach ( user => {
40
- this . emailUserMap [ user . email ] = user ;
37
+ if ( this . waitingQueryEmails . length > 0 ) {
38
+ this . api ( this . waitingQueryEmails ) . then ( res => {
39
+ const { user_list } = res . data ;
40
+ user_list . forEach ( user => {
41
+ this . emailUserMap [ user . email ] = user ;
42
+ } ) ;
43
+ this . queryUserCallback ( ) ;
44
+ } ) . catch ( ( ) => {
45
+ this . waitingQueryEmails . forEach ( email => {
46
+ this . emailUserMap [ email ] = {
47
+ email : email ,
48
+ name : email ,
49
+ avatar_url : this . defaultAvatarUrl ,
50
+ } ;
51
+ } ) ;
52
+ this . queryUserCallback ( ) ;
41
53
} ) ;
42
- this . queryUserCallback ( ) ;
43
- } ) . catch ( ( ) => {
44
- this . waitingQueryEmails . forEach ( email => {
45
- this . emailUserMap [ email ] = {
46
- email : email ,
47
- name : email ,
48
- avatar_url : this . defaultAvatarUrl ,
49
- } ;
50
- } ) ;
51
- this . queryUserCallback ( ) ;
52
- } ) ;
54
+ }
53
55
clearTimeout ( this . pendingTimer ) ;
54
56
this . pendingTimer = null ;
55
57
} , PENDING_INTERVAL ) ;
0 commit comments