Commit 818f7241 authored by Mattermost Build's avatar Mattermost Build Committed by Hossein Ahmadian-Yazdi

add updating roles in redux (#999)

parent f6284aa1
......@@ -23,6 +23,7 @@ import {getTeam, getMyTeamUnreads, getMyTeams, getMyTeamMembers} from './teams';
import {getPost, getPosts, getProfilesAndStatusesForPosts, getCustomEmojiForReaction, getUnreadPostData, handleNewPost, postDeleted, receivedPost} from './posts';
import {fetchMyChannelsAndMembers, getChannelAndMyMember, getChannelStats, markChannelAsRead} from './channels';
import {checkForModifiedUsers, getMe, getProfilesByIds, getStatusesByIds, loadProfilesForDirect} from './users';
import {loadRolesIfNeeded} from './roles';
import {Channel, ChannelMembership} from 'types/channels';
import {Dictionary} from 'types/utilities';
import {PreferenceType} from 'types/preferences';
......@@ -257,6 +258,9 @@ function handleEvent(msg: WebSocketMessage) {
case WebsocketEvents.ROLE_UPDATED:
doDispatch(handleRoleUpdatedEvent(msg));
break;
case WebsocketEvents.USER_ROLE_UPDATED:
doDispatch(handleUserRoleUpdated(msg));
break;
case WebsocketEvents.CHANNEL_CREATED:
doDispatch(handleChannelCreatedEvent(msg));
break;
......@@ -411,6 +415,14 @@ function handleTeamAddedEvent(msg: WebSocketMessage) {
};
}
function handleUserRoleUpdated(msg: WebSocketMessage) {
return (dispatch: DispatchFunc) => {
const roles = msg.data.roles.split(' ');
dispatch(loadRolesIfNeeded(roles));
return {data: true};
};
}
function handleUserAddedEvent(msg: WebSocketMessage) {
return (dispatch: DispatchFunc, getState: GetStateFunc) => {
const state = getState();
......
......@@ -18,6 +18,7 @@ const WebsocketEvents = {
USER_ADDED: 'user_added',
USER_REMOVED: 'user_removed',
USER_UPDATED: 'user_updated',
USER_ROLE_UPDATED: 'user_role_updated',
ROLE_ADDED: 'role_added',
ROLE_REMOVED: 'role_removed',
ROLE_UPDATED: 'role_updated',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment