mirror of
https://github.com/mattermost/focalboard.git
synced 2025-01-23 18:34:02 +02:00
Added logic to add board member to my memberships is it is for me (#3388)
This commit is contained in:
parent
3c8f85f08c
commit
1e1854a5dd
@ -24,6 +24,7 @@ import {
|
||||
getCurrentBoardId,
|
||||
setCurrent as setCurrentBoard,
|
||||
fetchBoardMembers,
|
||||
addMyBoardMemberships,
|
||||
} from '../../store/boards'
|
||||
import {getCurrentViewId, setCurrent as setCurrentView} from '../../store/views'
|
||||
import {initialLoad, initialReadOnlyLoad, loadBoardData} from '../../store/initialLoad'
|
||||
@ -126,8 +127,14 @@ const BoardPage = (props: Props): JSX.Element => {
|
||||
|
||||
const incrementalBoardMemberUpdate = (_: WSClient, members: BoardMember[]) => {
|
||||
dispatch(updateMembersEnsuringBoardsAndUsers(members))
|
||||
|
||||
if (me) {
|
||||
const myBoardMemberships = members.filter((boardMember) => boardMember.userId === me.id)
|
||||
dispatch(addMyBoardMemberships(myBoardMemberships))
|
||||
}
|
||||
}
|
||||
|
||||
console.log('useWEbsocket adding onChange handler')
|
||||
wsClient.addOnChange(incrementalBlockUpdate, 'block')
|
||||
wsClient.addOnChange(incrementalBoardUpdate, 'board')
|
||||
wsClient.addOnChange(incrementalBoardMemberUpdate, 'boardMembers')
|
||||
@ -145,6 +152,7 @@ const BoardPage = (props: Props): JSX.Element => {
|
||||
})
|
||||
|
||||
return () => {
|
||||
console.log('useWebsocket cleanup')
|
||||
wsClient.removeOnChange(incrementalBlockUpdate, 'block')
|
||||
wsClient.removeOnChange(incrementalBoardUpdate, 'board')
|
||||
wsClient.removeOnChange(incrementalBoardMemberUpdate, 'boardMembers')
|
||||
|
@ -135,6 +135,9 @@ const boardsSlice = createSlice({
|
||||
}
|
||||
},
|
||||
updateMembers: updateMembersHandler,
|
||||
addMyBoardMemberships: (state, action: PayloadAction<BoardMember[]>) => {
|
||||
action.payload.forEach((boardMember) => state.myBoardMemberships[boardMember.boardId] = boardMember)
|
||||
}
|
||||
},
|
||||
|
||||
extraReducers: (builder) => {
|
||||
@ -196,7 +199,7 @@ const boardsSlice = createSlice({
|
||||
},
|
||||
})
|
||||
|
||||
export const {updateBoards, setCurrent, setLinkToChannel, updateMembers} = boardsSlice.actions
|
||||
export const {updateBoards, setCurrent, setLinkToChannel, updateMembers, addMyBoardMemberships} = boardsSlice.actions
|
||||
export const {reducer} = boardsSlice
|
||||
|
||||
export const getBoards = (state: RootState): {[key: string]: Board} => state.boards?.boards || {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user