1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-01-26 18:48:15 +02:00

Fixed a bug where rmeoved board members showed up in comment list (#3223)

* Fixed a bug where rmeoved board members showed up in comment list

* Review fixes
This commit is contained in:
Harshil Sharma 2022-07-05 13:24:31 +05:30 committed by GitHub
parent d414d5cc5e
commit b5d8f2b9e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 3 deletions

View File

@ -28,6 +28,7 @@ import {updateViews} from './store/views'
import {updateCards} from './store/cards'
import {updateComments} from './store/comments'
import {updateContents} from './store/contents'
import {addBoardUsers, removeBoardUsersById} from "./store/users"
function updateAllBoardsAndBlocks(boards: Board[], blocks: Block[]) {
return batch(() => {
@ -384,9 +385,14 @@ class Mutator {
await undoManager.perform(
async () => {
await octoClient.deleteBoardMember(member)
store.dispatch(removeBoardUsersById([member.userId]))
},
async () => {
await octoClient.createBoardMember(member)
const user = await octoClient.getUser(member.userId)
if (user) {
store.dispatch(addBoardUsers([user]))
}
},
description,
this.undoGroupId,

View File

@ -9,7 +9,7 @@ import {IUser} from '../user'
import {initialLoad, initialReadOnlyLoad, loadBoardData} from './initialLoad'
import {addBoardUsers, setBoardUsers} from './users'
import {addBoardUsers, removeBoardUsersById, setBoardUsers} from './users'
import {RootState} from './index'
@ -81,7 +81,12 @@ export const updateMembersEnsuringBoardsAndUsers = createAsyncThunk(
}
const user = await client.getUser(m.userId)
if (user) {
thunkAPI.dispatch(addBoardUsers([user]))
const deleted = !m.schemeAdmin && !m.schemeEditor && !m.schemeViewer && !m.schemeCommenter
if (deleted) {
thunkAPI.dispatch(removeBoardUsersById([user.id]))
} else {
thunkAPI.dispatch(addBoardUsers([user]))
}
}
})

View File

@ -60,6 +60,11 @@ const usersSlice = createSlice({
state.boardUsers[user.id] = user
})
},
removeBoardUsersById: (state, action: PayloadAction<string[]>) => {
action.payload.forEach((userId: string) => {
delete state.boardUsers[userId]
})
},
followBlock: (state, action: PayloadAction<Subscription>) => {
state.blockSubscriptions.push(action.payload)
},
@ -97,7 +102,7 @@ const usersSlice = createSlice({
},
})
export const {setMe, setBoardUsers, addBoardUsers, followBlock, unfollowBlock, patchProps} = usersSlice.actions
export const {setMe, setBoardUsers, removeBoardUsersById, addBoardUsers, followBlock, unfollowBlock, patchProps} = usersSlice.actions
export const {reducer} = usersSlice
export const getMe = (state: RootState): IUser|null => state.users.me