Skip to content

Commit b1fc3db

Browse files
Andreas OmayratAlex Terentiev
authored andcommitted
Updated if-statement to better check for arrays
1 parent 6e7dfda commit b1fc3db

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/services/PeopleSearchService.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default class SPPeopleSearchService {
7676
return (mockUsers && mockUsers.length > 0) ? mockUsers[0] : null;
7777
} else {
7878
// If groupId is array, load data from all groups
79-
if (groupId !== null && typeof(groupId) === 'object') {
79+
if (Array.isArray(groupId)) {
8080
let userResults: IPeoplePickerUserItem[] = [];
8181
for (const id of groupId) {
8282
let tmpResults = await this.searchTenant(siteUrl, email, 1, principalTypes, ensureUser, id);
@@ -88,7 +88,7 @@ export default class SPPeopleSearchService {
8888
let filteredUserResults = userResults.filter(({loginName}, index) => !logins.includes(loginName, index + 1));
8989
return (filteredUserResults && filteredUserResults.length > 0) ? filteredUserResults[0] : null;
9090
} else {
91-
const userResults = await this.searchTenant(siteUrl, email, 1, principalTypes, ensureUser, groupId as string|number);
91+
const userResults = await this.searchTenant(siteUrl, email, 1, principalTypes, ensureUser, groupId);
9292
return (userResults && userResults.length > 0) ? userResults[0] : null;
9393
}
9494
}
@@ -103,7 +103,7 @@ export default class SPPeopleSearchService {
103103
return this.searchPeopleFromMock(query);
104104
} else {
105105
// If groupId is array, load data from all groups
106-
if (groupId !== null && typeof(groupId) === 'object') {
106+
if (Array.isArray(groupId)) {
107107
let userResults: IPeoplePickerUserItem[] = [];
108108
for (const id of groupId) {
109109
let tmpResults = await this.searchTenant(siteUrl, query, maximumSuggestions, principalTypes, ensureUser, id);
@@ -115,7 +115,7 @@ export default class SPPeopleSearchService {
115115
let filteredUserResults = userResults.filter(({loginName}, index) => !logins.includes(loginName, index + 1));
116116
return filteredUserResults;
117117
} else {
118-
return await this.searchTenant(siteUrl, query, maximumSuggestions, principalTypes, ensureUser, groupId as string|number);
118+
return await this.searchTenant(siteUrl, query, maximumSuggestions, principalTypes, ensureUser, groupId);
119119
}
120120
}
121121
}

0 commit comments

Comments
 (0)