mattermost-mobile/app/actions/websocket/groups.ts
Elias Nahum a6dd6e65ff
MM-24895 Load team member and roles in the WebSocket event (#4603)
* Load team member and roles in the WebSocket event

* Split WebSocket actions and events into multiple files
2020-07-23 13:29:27 -04:00

23 lines
No EOL
770 B
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {GroupTypes} from '@mm-redux/action_types';
import {ActionResult, DispatchFunc, batchActions} from '@mm-redux/types/actions';
import {WebSocketMessage} from '@mm-redux/types/websocket';
export function handleGroupUpdatedEvent(msg: WebSocketMessage) {
return (dispatch: DispatchFunc): ActionResult => {
const data = JSON.parse(msg.data.group);
dispatch(batchActions([
{
type: GroupTypes.RECEIVED_GROUP,
data,
},
{
type: GroupTypes.RECEIVED_MY_GROUPS,
data: [data],
},
]));
return {data: true};
};
}