* Add linter rules for import order and type member delimiters * Remove unneeded group * Group all app/* imports before the internal imports * Move app/ imports before parent imports * Separate @node_modules imports into a different group * Substitute app paths by aliases * Fix @node_modules import order and add test related modules * Add aliases for types and test, and group import types
49 lines
1.5 KiB
TypeScript
49 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 {GenericAction} from '@mm-redux/types/actions';
|
|
import {PostsRequestsStatuses, RequestStatusType} from '@mm-redux/types/requests';
|
|
|
|
import {handleRequest, initialRequestState} from './helpers';
|
|
|
|
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);
|