From 12ddeebedfdf3e7067c99a6f465eb52541a8466b Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Tue, 18 Dec 2018 04:54:32 +0100 Subject: [PATCH] Registered first actions as services --- src/container/index.js | 7 ++++++- src/short-urls/reducers/shortUrlTags.js | 10 +++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/container/index.js b/src/container/index.js index da38f008..8d4f97da 100644 --- a/src/container/index.js +++ b/src/container/index.js @@ -136,10 +136,15 @@ bottle.decorator('DeleteShortUrlModal', connectDecorator( [ 'shortUrlDeletion' ], { deleteShortUrl, resetDeleteShortUrl, shortUrlDeleted } )); + +bottle.serviceFactory('editShortUrlTags', editShortUrlTags, 'ShlinkApiClient'); +bottle.serviceFactory('resetShortUrlsTags', () => resetShortUrlsTags); +bottle.serviceFactory('shortUrlTagsEdited', () => shortUrlTagsEdited); + bottle.serviceFactory('EditTagsModal', EditTagsModal, 'TagsSelector'); bottle.decorator('EditTagsModal', connectDecorator( [ 'shortUrlTags' ], - { editShortUrlTags, resetShortUrlsTags, shortUrlTagsEdited } + [ 'editShortUrlTags', 'resetShortUrlsTags', 'shortUrlTagsEdited' ] )); export default container; diff --git a/src/short-urls/reducers/shortUrlTags.js b/src/short-urls/reducers/shortUrlTags.js index 597c5a89..c1f5646d 100644 --- a/src/short-urls/reducers/shortUrlTags.js +++ b/src/short-urls/reducers/shortUrlTags.js @@ -1,6 +1,5 @@ -import { curry } from 'ramda'; import PropTypes from 'prop-types'; -import shlinkApiClient from '../../api/ShlinkApiClient'; +import { pick } from 'ramda'; /* eslint-disable padding-line-between-statements, newline-after-var */ export const EDIT_SHORT_URL_TAGS_START = 'shlink/shortUrlTags/EDIT_SHORT_URL_TAGS_START'; @@ -40,8 +39,7 @@ export default function reducer(state = defaultState, action) { }; case EDIT_SHORT_URL_TAGS: return { - shortCode: action.shortCode, - tags: action.tags, + ...pick([ 'shortCode', 'tags' ], action), saving: false, error: false, }; @@ -52,7 +50,7 @@ export default function reducer(state = defaultState, action) { } } -export const _editShortUrlTags = (shlinkApiClient, shortCode, tags) => async (dispatch) => { +export const editShortUrlTags = (shlinkApiClient) => (shortCode, tags) => async (dispatch) => { dispatch({ type: EDIT_SHORT_URL_TAGS_START }); try { @@ -66,8 +64,6 @@ export const _editShortUrlTags = (shlinkApiClient, shortCode, tags) => async (di } }; -export const editShortUrlTags = curry(_editShortUrlTags)(shlinkApiClient); - export const resetShortUrlsTags = () => ({ type: RESET_EDIT_SHORT_URL_TAGS }); export const shortUrlTagsEdited = (shortCode, tags) => ({