Update client dependencies
This commit is contained in:
parent
383ca39354
commit
d023f63a7c
9 changed files with 48 additions and 41 deletions
|
@ -1,14 +1,14 @@
|
|||
import { pushPath } from 'redux-simple-router';
|
||||
import { routeActions } from 'redux-simple-router';
|
||||
import * as actions from '../actions';
|
||||
|
||||
export function select(server, channel, pm) {
|
||||
if (pm) {
|
||||
return pushPath(`/${server}/pm/${channel}`);
|
||||
return routeActions.push(`/${server}/pm/${channel}`);
|
||||
} else if (channel) {
|
||||
return pushPath(`/${server}/${encodeURIComponent(channel)}`);
|
||||
return routeActions.push(`/${server}/${encodeURIComponent(channel)}`);
|
||||
}
|
||||
|
||||
return pushPath(`/${server}`);
|
||||
return routeActions.push(`/${server}`);
|
||||
}
|
||||
|
||||
export function updateSelection() {
|
||||
|
@ -19,14 +19,14 @@ export function updateSelection() {
|
|||
const { server } = state.tab.selected;
|
||||
|
||||
if (servers.size === 0) {
|
||||
dispatch(pushPath('/connect'));
|
||||
dispatch(routeActions.replace('/connect'));
|
||||
} else if (history.size > 0) {
|
||||
const tab = history.last();
|
||||
dispatch(select(tab.server, tab.channel || tab.user, tab.user));
|
||||
} else if (servers.has(server)) {
|
||||
dispatch(select(server));
|
||||
} else {
|
||||
dispatch(pushPath('/'));
|
||||
dispatch(routeActions.replace('/'));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { pushPath } from 'redux-simple-router';
|
||||
import { routeActions } from 'redux-simple-router';
|
||||
import pure from 'pure-render-decorator';
|
||||
import TabList from '../components/TabList';
|
||||
import { select } from '../actions/tab';
|
||||
|
@ -32,4 +32,4 @@ function mapStateToProps(state) {
|
|||
};
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, { pushPath, select, hideMenu })(App);
|
||||
export default connect(mapStateToProps, { pushPath: routeActions.push, select, hideMenu })(App);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import React from 'react';
|
||||
import { render } from 'react-dom';
|
||||
import { syncReduxAndRouter } from 'redux-simple-router';
|
||||
import createBrowserHistory from 'history/lib/createBrowserHistory';
|
||||
import { browserHistory } from 'react-router';
|
||||
import configureStore from './store';
|
||||
import createRoutes from './routes';
|
||||
import Socket from './util/Socket';
|
||||
|
@ -9,14 +8,14 @@ import handleSocket from './socket';
|
|||
import Root from './containers/Root';
|
||||
|
||||
const host = __DEV__ ? `${window.location.hostname}:1337` : window.location.host;
|
||||
|
||||
const socket = new Socket(host);
|
||||
const store = configureStore(socket);
|
||||
handleSocket(socket, store);
|
||||
|
||||
const history = createBrowserHistory();
|
||||
syncReduxAndRouter(history, store);
|
||||
const store = configureStore(socket, browserHistory);
|
||||
handleSocket(socket, store);
|
||||
|
||||
const routes = createRoutes();
|
||||
|
||||
render(<Root store={store} routes={routes} history={history} />, document.getElementById('root'));
|
||||
render(
|
||||
<Root store={store} routes={routes} history={browserHistory} />,
|
||||
document.getElementById('root')
|
||||
);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Map, Record } from 'immutable';
|
||||
import createReducer from '../util/createReducer';
|
||||
import * as actions from '../actions';
|
||||
import forEach from 'lodash/collection/forEach';
|
||||
import forEach from 'lodash/forEach';
|
||||
|
||||
const Server = Record({
|
||||
nick: null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { replacePath } from 'redux-simple-router';
|
||||
import { routeActions } from 'redux-simple-router';
|
||||
import { broadcast, inform, addMessage, addMessages } from './actions/message';
|
||||
import { select } from './actions/tab';
|
||||
import { normalizeChannel } from './util';
|
||||
|
@ -37,7 +37,7 @@ export default function handleSocket(socket, { dispatch, getState }) {
|
|||
|
||||
socket.on('servers', data => {
|
||||
if (!data) {
|
||||
dispatch(replacePath('/connect'));
|
||||
dispatch(routeActions.replace('/connect'));
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
import { createStore, applyMiddleware, compose } from 'redux';
|
||||
import thunk from 'redux-thunk';
|
||||
import { syncHistory } from 'redux-simple-router';
|
||||
import reducer from '../reducers';
|
||||
import createSocketMiddleware from '../middleware/socket';
|
||||
import commands from '../commands';
|
||||
import DevTools from '../containers/DevTools';
|
||||
|
||||
export default function configureStore(socket, initialState) {
|
||||
export default function configureStore(socket, history, initialState) {
|
||||
const reduxRouterMiddleware = syncHistory(history);
|
||||
|
||||
const finalCreateStore = compose(
|
||||
applyMiddleware(
|
||||
reduxRouterMiddleware,
|
||||
thunk,
|
||||
createSocketMiddleware(socket),
|
||||
commands
|
||||
|
@ -17,6 +21,8 @@ export default function configureStore(socket, initialState) {
|
|||
|
||||
const store = finalCreateStore(reducer, initialState);
|
||||
|
||||
reduxRouterMiddleware.listenForReplays(store);
|
||||
|
||||
if (module.hot) {
|
||||
module.hot.accept('../reducers', () => {
|
||||
store.replaceReducer(require('../reducers').default);
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import { createStore, applyMiddleware } from 'redux';
|
||||
import thunk from 'redux-thunk';
|
||||
import { syncHistory } from 'redux-simple-router';
|
||||
import reducer from '../reducers';
|
||||
import createSocketMiddleware from '../middleware/socket';
|
||||
import commands from '../commands';
|
||||
|
||||
export default function configureStore(socket, initialState) {
|
||||
export default function configureStore(socket, history, initialState) {
|
||||
const finalCreateStore = applyMiddleware(
|
||||
syncHistory(history),
|
||||
thunk,
|
||||
createSocketMiddleware(socket),
|
||||
commands
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue