c119c44c13
When this is merged https://gitlab.com/ligolang/ligo-web-ide/ will be marked as deprecated. This MR does not hook up the webide build to the main CI. The CI integration will come in a subsequent MR for the sake of making review easier.
32 lines
813 B
TypeScript
32 lines
813 B
TypeScript
import { applyMiddleware, createStore, Middleware } from 'redux';
|
|
import ReduxThunk from 'redux-thunk';
|
|
|
|
import rootReducer, { AppState } from './redux/app';
|
|
|
|
declare var defaultServerState: AppState | undefined;
|
|
|
|
export default function configureStore() {
|
|
const store = createStore(
|
|
rootReducer,
|
|
{
|
|
...(typeof defaultServerState === 'undefined' ? {} : defaultServerState)
|
|
},
|
|
applyMiddleware(ReduxThunk, cleanRouteOnAction)
|
|
);
|
|
|
|
return store;
|
|
}
|
|
|
|
const cleanRouteOnAction: Middleware = store => next => action => {
|
|
const { share } = store.getState();
|
|
next(action);
|
|
const state = store.getState();
|
|
if (
|
|
share.link !== undefined &&
|
|
state.share.link === undefined &&
|
|
window.location.pathname !== '/'
|
|
) {
|
|
window.history.replaceState({}, document.title, '/');
|
|
}
|
|
};
|