* Remove mattermost-redux * Move mm-redux files into app/redux * Add @redux path to tsconfig.json * Fix imports * Install missing dependencies * Fix tsc errors * Fix i18n_utils test * Fix more imports * Remove redux websocket * Fix tests * Rename @redux * Apply changes from mattermost-redux PR 1103 * Remove mattermost-redux mention in template * Add missing imports * Rename app/redux/ to app/mm-redux/ * Remove test file * Fix fetching Sidebar GM profiles Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
import {combineReducers} from 'redux';
|
|
import {PostTypes} from '@mm-redux/action_types';
|
|
import {handleRequest, initialRequestState} from './helpers';
|
|
import {GenericAction} from '@mm-redux/types/actions';
|
|
import {PostsRequestsStatuses, RequestStatusType} from '@mm-redux/types/requests';
|
|
|
|
function createPost(state: RequestStatusType = initialRequestState(), action: GenericAction): RequestStatusType {
|
|
if (action.type === PostTypes.CREATE_POST_RESET_REQUEST) {
|
|
return initialRequestState();
|
|
}
|
|
|
|
return handleRequest(
|
|
PostTypes.CREATE_POST_REQUEST,
|
|
PostTypes.CREATE_POST_SUCCESS,
|
|
PostTypes.CREATE_POST_FAILURE,
|
|
state,
|
|
action
|
|
);
|
|
}
|
|
|
|
function editPost(state: RequestStatusType = initialRequestState(), action: GenericAction): RequestStatusType {
|
|
return handleRequest(
|
|
PostTypes.EDIT_POST_REQUEST,
|
|
PostTypes.EDIT_POST_SUCCESS,
|
|
PostTypes.EDIT_POST_FAILURE,
|
|
state,
|
|
action
|
|
);
|
|
}
|
|
|
|
function getPostThread(state: RequestStatusType = initialRequestState(), action: GenericAction): RequestStatusType {
|
|
return handleRequest(
|
|
PostTypes.GET_POST_THREAD_REQUEST,
|
|
PostTypes.GET_POST_THREAD_SUCCESS,
|
|
PostTypes.GET_POST_THREAD_FAILURE,
|
|
state,
|
|
action
|
|
);
|
|
}
|
|
|
|
export default (combineReducers({
|
|
createPost,
|
|
editPost,
|
|
getPostThread,
|
|
}) as (b: PostsRequestsStatuses, a: GenericAction) => PostsRequestsStatuses);
|