Skip to content

Commit c738605

Browse files
杨国璇杨国璇
authored andcommitted
fix: user service
1 parent 00e8d7b commit c738605

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

frontend/src/metadata/services/user-service.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class UserService {
2323
let validEmails = [];
2424
emails.forEach(email => {
2525
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;
2727
validEmails.push(email);
2828
});
2929
if (validEmails.length === 0) return;
@@ -32,24 +32,26 @@ class UserService {
3232
};
3333

3434
startQueryUsers = () => {
35-
if (this.pendingTimer || this.waitingQueryEmails.length === 0) return;
35+
if (this.pendingTimer) return;
3636
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();
4153
});
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+
}
5355
clearTimeout(this.pendingTimer);
5456
this.pendingTimer = null;
5557
}, PENDING_INTERVAL);

0 commit comments

Comments
 (0)