Skip to content

Commit

Permalink
MM-23395: Add websockets support for update group (mattermost#5245)
Browse files Browse the repository at this point in the history
* MM-23395: add websockets support for update group
  • Loading branch information
catalintomai committed May 18, 2020
1 parent d127865 commit ea6e0bb
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
57 changes: 57 additions & 0 deletions actions/websocket_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {batchActions} from 'redux-batched-actions';
import {
ChannelTypes,
EmojiTypes,
GroupTypes,
PostTypes,
TeamTypes,
UserTypes,
Expand Down Expand Up @@ -424,6 +425,26 @@ export function handleEvent(msg) {
handleOpenDialogEvent(msg);
break;

case SocketEvents.RECEIVED_GROUP:
handleGroupUpdatedEvent(msg);
break;

case SocketEvents.RECEIVED_GROUP_ASSOCIATED_TO_TEAM:
handleGroupAssociatedToTeamEvent(msg);
break;

case SocketEvents.RECEIVED_GROUP_NOT_ASSOCIATED_TO_TEAM:
handleGroupNotAssociatedToTeamEvent(msg);
break;

case SocketEvents.RECEIVED_GROUP_ASSOCIATED_TO_CHANNEL:
handleGroupAssociatedToChannelEvent(msg);
break;

case SocketEvents.RECEIVED_GROUP_NOT_ASSOCIATED_TO_CHANNEL:
handleGroupNotAssociatedToChannelEvent(msg);
break;

default:
}

Expand Down Expand Up @@ -1127,3 +1148,39 @@ function handleOpenDialogEvent(msg) {

store.dispatch(openModal({modalId: ModalIdentifiers.INTERACTIVE_DIALOG, dialogType: InteractiveDialog}));
}

function handleGroupUpdatedEvent(msg) {
const data = JSON.parse(msg.data.group);
store.dispatch({
type: GroupTypes.RECEIVED_GROUP,
data,
});
}

function handleGroupAssociatedToTeamEvent(msg) {
store.dispatch({
type: GroupTypes.RECEIVED_GROUP_ASSOCIATED_TO_TEAM,
data: {teamID: msg.broadcast.team_id, groups: [{id: msg.data.group_id}]}
});
}

function handleGroupNotAssociatedToTeamEvent(msg) {
store.dispatch({
type: GroupTypes.RECEIVED_GROUP_NOT_ASSOCIATED_TO_TEAM,
data: {teamID: msg.broadcast.team_id, groups: [{id: msg.data.group_id}]}
});
}

function handleGroupAssociatedToChannelEvent(msg) {
store.dispatch({
type: GroupTypes.RECEIVED_GROUP_ASSOCIATED_TO_CHANNEL,
data: {channelID: msg.broadcast.channel_id, groups: [{id: msg.data.group_id}]}
});
}

function handleGroupNotAssociatedToChannelEvent(msg) {
store.dispatch({
type: GroupTypes.RECEIVED_GROUP_NOT_ASSOCIATED_TO_CHANNEL,
data: {channelID: msg.broadcast.channel_id, groups: [{id: msg.data.group_id}]}
});
}
5 changes: 5 additions & 0 deletions utils/constants.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,11 @@ export const SocketEvents = {
CONFIG_CHANGED: 'config_changed',
PLUGIN_STATUSES_CHANGED: 'plugin_statuses_changed',
OPEN_DIALOG: 'open_dialog',
RECEIVED_GROUP: 'received_group',
RECEIVED_GROUP_ASSOCIATED_TO_TEAM: 'received_group_associated_to_team',
RECEIVED_GROUP_NOT_ASSOCIATED_TO_TEAM: 'received_group_not_associated_to_team',
RECEIVED_GROUP_ASSOCIATED_TO_CHANNEL: 'received_group_associated_to_channel',
RECEIVED_GROUP_NOT_ASSOCIATED_TO_CHANNEL: 'received_group_not_associated_to_channel',
};

export const TutorialSteps = {
Expand Down

0 comments on commit ea6e0bb

Please sign in to comment.