MM-54356: In-correct User count when adding members that already exists to the channel (#24540)

* Only add user who isn't in the channel

* Update webapp/channels/src/packages/mattermost-redux/src/actions/channels.ts

Co-authored-by: Devin Binnie <52460000+devinbinnie@users.noreply.github.com>

---------

Co-authored-by: Devin Binnie <52460000+devinbinnie@users.noreply.github.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
Alex DeCamillo 2023-09-18 23:48:59 -07:00 committed by GitHub
parent ccfb4a3d74
commit d08f1ca3fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1049,20 +1049,23 @@ export function addChannelMember(channelId: string, userId: string, postRootId =
Client4.trackEvent('action', 'action_channels_add_member', {channel_id: channelId});
dispatch(batchActions([
{
type: UserTypes.RECEIVED_PROFILE_IN_CHANNEL,
data: {id: channelId, user_id: userId},
},
{
type: ChannelTypes.RECEIVED_CHANNEL_MEMBER,
data: member,
},
{
type: ChannelTypes.ADD_CHANNEL_MEMBER_SUCCESS,
id: channelId,
},
], 'ADD_CHANNEL_MEMBER.BATCH'));
const membersInChannel = getState().entities.channels.membersInChannel[channelId];
if (!(membersInChannel && userId in membersInChannel)) {
dispatch(batchActions([
{
type: UserTypes.RECEIVED_PROFILE_IN_CHANNEL,
data: {id: channelId, user_id: userId},
},
{
type: ChannelTypes.RECEIVED_CHANNEL_MEMBER,
data: member,
},
{
type: ChannelTypes.ADD_CHANNEL_MEMBER_SUCCESS,
id: channelId,
},
], 'ADD_CHANNEL_MEMBER.BATCH'));
}
return {data: member};
};