mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-04-12 01:26:21 +00:00
Fixed changing selected server
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
import ShlinkApiClient from '../../api/ShlinkApiClient';
|
||||
import ServersService from '../../servers/services/ServersService';
|
||||
import { resetShortUrlParams } from '../../short-urls/reducers/shortUrlsListParams'
|
||||
|
||||
const SELECT_SERVER = 'shlink/selectedServer/SELECT_SERVER';
|
||||
const RESET_SELECTED_SERVER = 'shlink/selectedServer/RESET_SELECTED_SERVER';
|
||||
|
||||
export default function reducer(state = null, action) {
|
||||
const defaultState = null;
|
||||
|
||||
export default function reducer(state = defaultState, action) {
|
||||
switch (action.type) {
|
||||
case SELECT_SERVER:
|
||||
return action.selectedServer;
|
||||
case RESET_SELECTED_SERVER:
|
||||
return null;
|
||||
return defaultState;
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
@@ -17,12 +20,14 @@ export default function reducer(state = null, action) {
|
||||
|
||||
export const resetSelectedServer = () => ({ type: RESET_SELECTED_SERVER });
|
||||
|
||||
export const selectServer = serverId => {
|
||||
export const selectServer = serverId => dispatch => {
|
||||
dispatch(resetShortUrlParams());
|
||||
|
||||
const selectedServer = ServersService.findServerById(serverId);
|
||||
ShlinkApiClient.setConfig(selectedServer);
|
||||
|
||||
return {
|
||||
dispatch({
|
||||
type: SELECT_SERVER,
|
||||
selectedServer
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user