Skip to content

Commit

Permalink
Displayed only board members in autocomplete (mattermost-community#2969)
Browse files Browse the repository at this point in the history
* Displayed only board members in autocomplete

* Removed debug logs
  • Loading branch information
harshilsharma63 authored May 3, 2022
1 parent 24ff8d5 commit 4a99a91
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions webapp/src/store/boards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {IUser} from '../user'

import {initialLoad, initialReadOnlyLoad, loadBoardData} from './initialLoad'

import {addBoardUsers} from './users'
import {addBoardUsers, setBoardUsers} from './users'

import {RootState} from './index'

Expand All @@ -26,22 +26,19 @@ export const fetchBoardMembers = createAsyncThunk(
'boardMembers/fetch',
async ({teamId, boardId}: {teamId: string, boardId: string}, thunkAPI: any) => {
const members = await client.getBoardMembers(teamId, boardId)
const boardUsers = thunkAPI.getState().users.boardUsers as {[key: string]: IUser}
const newUsers = [] as IUser[]
const users = [] as IUser[]

/* eslint-disable no-await-in-loop */
for (const member of members) {
const memberFromStore = boardUsers[member.userId]
if (!memberFromStore) {
const user = await client.getUser(member.userId)
if (user) {
newUsers.push(user)
}
// TODO #2968 we should fetch this in bulk
const user = await client.getUser(member.userId)
if (user) {
users.push(user)
}
}
/* eslint-enable no-await-in-loop */

thunkAPI.dispatch(addBoardUsers(newUsers))
thunkAPI.dispatch(setBoardUsers(users))
return members
},
)
Expand Down

0 comments on commit 4a99a91

Please sign in to comment.