Replaced usages of defaultState by initialState

This commit is contained in:
Alejandro Celaya 2019-03-17 10:11:20 +01:00
parent 5bb9d15e27
commit 232c059e4f
8 changed files with 21 additions and 21 deletions

View file

@ -6,7 +6,7 @@ export const SELECT_SERVER = 'shlink/selectedServer/SELECT_SERVER';
export const RESET_SELECTED_SERVER = 'shlink/selectedServer/RESET_SELECTED_SERVER'; export const RESET_SELECTED_SERVER = 'shlink/selectedServer/RESET_SELECTED_SERVER';
/* eslint-enable padding-line-between-statements */ /* eslint-enable padding-line-between-statements */
const defaultState = null; const initialState = null;
export const resetSelectedServer = createAction(RESET_SELECTED_SERVER); export const resetSelectedServer = createAction(RESET_SELECTED_SERVER);
@ -22,6 +22,6 @@ export const selectServer = (serversService) => (serverId) => (dispatch) => {
}; };
export default handleActions({ export default handleActions({
[RESET_SELECTED_SERVER]: () => defaultState, [RESET_SELECTED_SERVER]: () => initialState,
[SELECT_SERVER]: (state, { selectedServer }) => selectedServer, [SELECT_SERVER]: (state, { selectedServer }) => selectedServer,
}, defaultState); }, initialState);

View file

@ -16,7 +16,7 @@ export const createShortUrlResultType = PropTypes.shape({
error: PropTypes.bool, error: PropTypes.bool,
}); });
const defaultState = { const initialState = {
result: null, result: null,
saving: false, saving: false,
error: false, error: false,
@ -26,8 +26,8 @@ export default handleActions({
[CREATE_SHORT_URL_START]: (state) => ({ ...state, saving: true, error: false }), [CREATE_SHORT_URL_START]: (state) => ({ ...state, saving: true, error: false }),
[CREATE_SHORT_URL_ERROR]: (state) => ({ ...state, saving: false, error: true }), [CREATE_SHORT_URL_ERROR]: (state) => ({ ...state, saving: false, error: true }),
[CREATE_SHORT_URL]: (state, { result }) => ({ result, saving: false, error: false }), [CREATE_SHORT_URL]: (state, { result }) => ({ result, saving: false, error: false }),
[RESET_CREATE_SHORT_URL]: () => defaultState, [RESET_CREATE_SHORT_URL]: () => initialState,
}, defaultState); }, initialState);
export const createShortUrl = (buildShlinkApiClient) => (data) => async (dispatch, getState) => { export const createShortUrl = (buildShlinkApiClient) => (data) => async (dispatch, getState) => {
dispatch({ type: CREATE_SHORT_URL_START }); dispatch({ type: CREATE_SHORT_URL_START });

View file

@ -19,7 +19,7 @@ export const shortUrlDeletionType = PropTypes.shape({
}).isRequired, }).isRequired,
}); });
const defaultState = { const initialState = {
shortCode: '', shortCode: '',
loading: false, loading: false,
error: false, error: false,
@ -30,8 +30,8 @@ export default handleActions({
[DELETE_SHORT_URL_START]: (state) => ({ ...state, loading: true, error: false }), [DELETE_SHORT_URL_START]: (state) => ({ ...state, loading: true, error: false }),
[DELETE_SHORT_URL_ERROR]: (state, { errorData }) => ({ ...state, errorData, loading: false, error: true }), [DELETE_SHORT_URL_ERROR]: (state, { errorData }) => ({ ...state, errorData, loading: false, error: true }),
[DELETE_SHORT_URL]: (state, { shortCode }) => ({ ...state, shortCode, loading: false, error: false }), [DELETE_SHORT_URL]: (state, { shortCode }) => ({ ...state, shortCode, loading: false, error: false }),
[RESET_DELETE_SHORT_URL]: () => defaultState, [RESET_DELETE_SHORT_URL]: () => initialState,
}, defaultState); }, initialState);
export const deleteShortUrl = (buildShlinkApiClient) => (shortCode) => async (dispatch, getState) => { export const deleteShortUrl = (buildShlinkApiClient) => (shortCode) => async (dispatch, getState) => {
dispatch({ type: DELETE_SHORT_URL_START }); dispatch({ type: DELETE_SHORT_URL_START });

View file

@ -17,7 +17,7 @@ export const shortUrlTagsType = PropTypes.shape({
error: PropTypes.bool.isRequired, error: PropTypes.bool.isRequired,
}); });
const defaultState = { const initialState = {
shortCode: null, shortCode: null,
tags: [], tags: [],
saving: false, saving: false,
@ -28,8 +28,8 @@ export default handleActions({
[EDIT_SHORT_URL_TAGS_START]: (state) => ({ ...state, saving: true, error: false }), [EDIT_SHORT_URL_TAGS_START]: (state) => ({ ...state, saving: true, error: false }),
[EDIT_SHORT_URL_TAGS_ERROR]: (state) => ({ ...state, saving: false, error: true }), [EDIT_SHORT_URL_TAGS_ERROR]: (state) => ({ ...state, saving: false, error: true }),
[EDIT_SHORT_URL_TAGS]: (state, action) => ({ ...pick([ 'shortCode', 'tags' ], action), saving: false, error: false }), [EDIT_SHORT_URL_TAGS]: (state, action) => ({ ...pick([ 'shortCode', 'tags' ], action), saving: false, error: false }),
[RESET_EDIT_SHORT_URL_TAGS]: () => defaultState, [RESET_EDIT_SHORT_URL_TAGS]: () => initialState,
}, defaultState); }, initialState);
export const editShortUrlTags = (buildShlinkApiClient) => (shortCode, tags) => async (dispatch, getState) => { export const editShortUrlTags = (buildShlinkApiClient) => (shortCode, tags) => async (dispatch, getState) => {
dispatch({ type: EDIT_SHORT_URL_TAGS_START }); dispatch({ type: EDIT_SHORT_URL_TAGS_START });

View file

@ -10,11 +10,11 @@ export const shortUrlsListParamsType = PropTypes.shape({
searchTerm: PropTypes.string, searchTerm: PropTypes.string,
}); });
const defaultState = { page: '1' }; const initialState = { page: '1' };
export default handleActions({ export default handleActions({
[LIST_SHORT_URLS]: (state, { params }) => ({ ...state, ...params }), [LIST_SHORT_URLS]: (state, { params }) => ({ ...state, ...params }),
[RESET_SHORT_URL_PARAMS]: () => defaultState, [RESET_SHORT_URL_PARAMS]: () => initialState,
}, defaultState); }, initialState);
export const resetShortUrlParams = createAction(RESET_SHORT_URL_PARAMS); export const resetShortUrlParams = createAction(RESET_SHORT_URL_PARAMS);

View file

@ -13,7 +13,7 @@ export const tagDeleteType = PropTypes.shape({
error: PropTypes.bool, error: PropTypes.bool,
}); });
const defaultState = { const initialState = {
deleting: false, deleting: false,
error: false, error: false,
}; };
@ -22,7 +22,7 @@ export default handleActions({
[DELETE_TAG_START]: () => ({ deleting: true, error: false }), [DELETE_TAG_START]: () => ({ deleting: true, error: false }),
[DELETE_TAG_ERROR]: () => ({ deleting: false, error: true }), [DELETE_TAG_ERROR]: () => ({ deleting: false, error: true }),
[DELETE_TAG]: () => ({ deleting: false, error: false }), [DELETE_TAG]: () => ({ deleting: false, error: false }),
}, defaultState); }, initialState);
export const deleteTag = (buildShlinkApiClient) => (tag) => async (dispatch, getState) => { export const deleteTag = (buildShlinkApiClient) => (tag) => async (dispatch, getState) => {
dispatch({ type: DELETE_TAG_START }); dispatch({ type: DELETE_TAG_START });

View file

@ -9,7 +9,7 @@ export const EDIT_TAG = 'shlink/editTag/EDIT_TAG';
export const TAG_EDITED = 'shlink/editTag/TAG_EDITED'; export const TAG_EDITED = 'shlink/editTag/TAG_EDITED';
const defaultState = { const initialState = {
oldName: '', oldName: '',
newName: '', newName: '',
editing: false, editing: false,
@ -24,7 +24,7 @@ export default handleActions({
editing: false, editing: false,
error: false, error: false,
}), }),
}, defaultState); }, initialState);
export const editTag = (buildShlinkApiClient, colorGenerator) => (oldName, newName, color) => async ( export const editTag = (buildShlinkApiClient, colorGenerator) => (oldName, newName, color) => async (
dispatch, dispatch,

View file

@ -11,7 +11,7 @@ const LIST_TAGS = 'shlink/tagsList/LIST_TAGS';
const FILTER_TAGS = 'shlink/tagsList/FILTER_TAGS'; const FILTER_TAGS = 'shlink/tagsList/FILTER_TAGS';
/* eslint-enable padding-line-between-statements */ /* eslint-enable padding-line-between-statements */
const defaultState = { const initialState = {
tags: [], tags: [],
filteredTags: [], filteredTags: [],
loading: false, loading: false,
@ -39,7 +39,7 @@ export default handleActions({
...state, ...state,
filteredTags: state.tags.filter((tag) => tag.toLowerCase().match(searchTerm)), filteredTags: state.tags.filter((tag) => tag.toLowerCase().match(searchTerm)),
}), }),
}, defaultState); }, initialState);
export const _listTags = (buildShlinkApiClient, force = false) => async (dispatch, getState) => { export const _listTags = (buildShlinkApiClient, force = false) => async (dispatch, getState) => {
const { tagsList, selectedServer } = getState(); const { tagsList, selectedServer } = getState();