UNPKG

mattermost-redux

Version:

Common code (API client, Redux stores, logic, utility functions) for building a Mattermost client

28 lines (22 loc) 912 B
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import {combineReducers} from 'redux'; import {GeneralTypes} from 'action_types'; import {GenericAction} from 'types/actions'; import {GeneralRequestsStatuses, RequestStatusType} from 'types/requests'; import {handleRequest, initialRequestState} from './helpers'; function websocket(state: RequestStatusType = initialRequestState(), action: GenericAction): RequestStatusType { if (action.type === GeneralTypes.WEBSOCKET_CLOSED) { return initialRequestState(); } return handleRequest( GeneralTypes.WEBSOCKET_REQUEST, GeneralTypes.WEBSOCKET_SUCCESS, GeneralTypes.WEBSOCKET_FAILURE, state, action, ); } export default (combineReducers({ websocket, }) as (b: GeneralRequestsStatuses, a: GenericAction) => GeneralRequestsStatuses);