Simplified ShlinkApiClient and moved runtime creation logic to external service

This commit is contained in:
Alejandro Celaya
2018-12-18 10:14:25 +01:00
parent 7bd4b39b5a
commit 4f54e3315f
14 changed files with 90 additions and 57 deletions

View File

@@ -1,4 +1,3 @@
import shlinkApiClient from '../../api/ShlinkApiClient';
import serversService from '../../servers/services/ServersService';
import { resetShortUrlParams } from '../../short-urls/reducers/shortUrlsListParams';
@@ -22,17 +21,15 @@ export default function reducer(state = defaultState, action) {
export const resetSelectedServer = () => ({ type: RESET_SELECTED_SERVER });
export const _selectServer = (shlinkApiClient, serversService) => (serverId) => (dispatch) => {
export const _selectServer = (serversService) => (serverId) => (dispatch) => {
dispatch(resetShortUrlParams());
const selectedServer = serversService.findServerById(serverId);
shlinkApiClient.setConfig(selectedServer);
dispatch({
type: SELECT_SERVER,
selectedServer,
});
};
export const selectServer = _selectServer(shlinkApiClient, serversService);
export const selectServer = _selectServer(serversService);