Update client dependencies
This commit is contained in:
parent
42efc20748
commit
81b635a872
18 changed files with 97 additions and 162 deletions
|
@ -64,7 +64,9 @@ export function addMessages(messages) {
|
|||
return (dispatch, getState) => {
|
||||
const state = getState();
|
||||
|
||||
messages.forEach(message => initMessage(message, state).time = now);
|
||||
messages.forEach(message => {
|
||||
initMessage(message, state).time = now;
|
||||
});
|
||||
|
||||
dispatch({
|
||||
type: actions.ADD_MESSAGES,
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import { routeActions } from 'react-router-redux';
|
||||
import { push, replace } from 'react-router-redux';
|
||||
import * as actions from '../actions';
|
||||
|
||||
export function select(server, channel, pm) {
|
||||
if (pm) {
|
||||
return routeActions.push(`/${server}/pm/${channel}`);
|
||||
return push(`/${server}/pm/${channel}`);
|
||||
} else if (channel) {
|
||||
return routeActions.push(`/${server}/${encodeURIComponent(channel)}`);
|
||||
return push(`/${server}/${encodeURIComponent(channel)}`);
|
||||
}
|
||||
|
||||
return routeActions.push(`/${server}`);
|
||||
return push(`/${server}`);
|
||||
}
|
||||
|
||||
export function updateSelection() {
|
||||
|
@ -19,14 +19,14 @@ export function updateSelection() {
|
|||
const { server } = state.tab.selected;
|
||||
|
||||
if (servers.size === 0) {
|
||||
dispatch(routeActions.replace('/connect'));
|
||||
dispatch(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(routeActions.replace('/'));
|
||||
dispatch(replace('/'));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import React, { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { routeActions } from 'react-router-redux';
|
||||
import { push } from 'react-router-redux';
|
||||
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: routeActions.push, select, hideMenu })(App);
|
||||
export default connect(mapStateToProps, { pushPath: push, select, hideMenu })(App);
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
import React from 'react';
|
||||
import { createDevTools } from 'redux-devtools';
|
||||
import DockMonitor from 'redux-devtools-dock-monitor';
|
||||
import LogMonitor from 'redux-devtools-log-monitor';
|
||||
|
||||
export default createDevTools(
|
||||
<DockMonitor toggleVisibilityKey="ctrl-h" changePositionKey="ctrl-q" defaultIsVisible={false}>
|
||||
<LogMonitor theme="tomorrow" />
|
||||
</DockMonitor>
|
||||
);
|
|
@ -1,18 +0,0 @@
|
|||
import React, { Component } from 'react';
|
||||
import { Router } from 'react-router';
|
||||
import { Provider } from 'react-redux';
|
||||
import DevTools from './DevTools';
|
||||
|
||||
export default class Root extends Component {
|
||||
render() {
|
||||
const { store, routes, history } = this.props;
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<div>
|
||||
<Router routes={routes} history={history} />
|
||||
<DevTools />
|
||||
</div>
|
||||
</Provider>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,14 @@
|
|||
if (__DEV__) {
|
||||
module.exports = require('./Root.dev');
|
||||
} else {
|
||||
module.exports = require('./Root.prod');
|
||||
import React, { Component } from 'react';
|
||||
import { Router } from 'react-router';
|
||||
import { Provider } from 'react-redux';
|
||||
|
||||
export default class Root extends Component {
|
||||
render() {
|
||||
const { store, routes, history } = this.props;
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<Router routes={routes} history={history} />
|
||||
</Provider>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
import React, { Component } from 'react';
|
||||
import { Router } from 'react-router';
|
||||
import { Provider } from 'react-redux';
|
||||
|
||||
export default class Root extends Component {
|
||||
render() {
|
||||
const { store, routes, history } = this.props;
|
||||
return (
|
||||
<Provider store={store}>
|
||||
<Router routes={routes} history={history} />
|
||||
</Provider>
|
||||
);
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
import React from 'react';
|
||||
import { render } from 'react-dom';
|
||||
import { browserHistory } from 'react-router';
|
||||
import { routeActions } from 'react-router-redux';
|
||||
import { syncHistoryWithStore, replace } from 'react-router-redux';
|
||||
import configureStore from './store';
|
||||
import createRoutes from './routes';
|
||||
import Socket from './util/Socket';
|
||||
|
@ -28,7 +28,7 @@ if (env.servers) {
|
|||
data: env.servers
|
||||
});
|
||||
} else {
|
||||
store.dispatch(routeActions.replace('/connect'));
|
||||
store.dispatch(replace('/connect'));
|
||||
}
|
||||
|
||||
if (env.channels) {
|
||||
|
@ -48,8 +48,9 @@ if (env.users) {
|
|||
handleSocket(socket, store);
|
||||
|
||||
const routes = createRoutes();
|
||||
const history = syncHistoryWithStore(browserHistory, store);
|
||||
|
||||
render(
|
||||
<Root store={store} routes={routes} history={browserHistory} />,
|
||||
<Root store={store} routes={routes} history={history} />,
|
||||
document.getElementById('root')
|
||||
);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { combineReducers } from 'redux';
|
||||
import { routeReducer } from 'react-router-redux';
|
||||
import { routerReducer } from 'react-router-redux';
|
||||
import channels from './channels';
|
||||
import environment from './environment';
|
||||
import input from './input';
|
||||
|
@ -12,7 +12,7 @@ import tab from './tab';
|
|||
import ui from './ui';
|
||||
|
||||
export default combineReducers({
|
||||
routing: routeReducer,
|
||||
routing: routerReducer,
|
||||
channels,
|
||||
environment,
|
||||
input,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Record, List } from 'immutable';
|
||||
import { UPDATE_LOCATION } from 'react-router-redux';
|
||||
import { LOCATION_CHANGE } from 'react-router-redux';
|
||||
import createReducer from '../util/createReducer';
|
||||
import * as actions from '../actions';
|
||||
|
||||
|
@ -38,7 +38,7 @@ export default createReducer(new State(), {
|
|||
return state.set('history', state.history.filter(tab => tab.server !== action.server));
|
||||
},
|
||||
|
||||
[UPDATE_LOCATION](state, action) {
|
||||
[LOCATION_CHANGE](state, action) {
|
||||
if (action.payload.pathname.indexOf('.') === -1 && state.selected.server) {
|
||||
return state.set('selected', new Tab());
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ function withReason(message, reason) {
|
|||
}
|
||||
|
||||
export default function handleSocket(socket, { dispatch, getState }) {
|
||||
socket.onAny(data => {
|
||||
const type = `SOCKET_${socket.event.toUpperCase()}`;
|
||||
socket.onAny((event, data) => {
|
||||
const type = `SOCKET_${event.toUpperCase()}`;
|
||||
if (Array.isArray(data)) {
|
||||
dispatch({ type, data });
|
||||
} else {
|
||||
|
|
|
@ -1,5 +1,20 @@
|
|||
if (__DEV__) {
|
||||
module.exports = require('./store.dev');
|
||||
} else {
|
||||
module.exports = require('./store.prod');
|
||||
import { createStore, applyMiddleware, compose } from 'redux';
|
||||
import thunk from 'redux-thunk';
|
||||
import { routerMiddleware } from 'react-router-redux';
|
||||
import reducer from '../reducers';
|
||||
import createSocketMiddleware from '../middleware/socket';
|
||||
import commands from '../commands';
|
||||
|
||||
export default function configureStore(socket, history, initialState) {
|
||||
const finalCreateStore = compose(
|
||||
applyMiddleware(
|
||||
routerMiddleware(history),
|
||||
thunk,
|
||||
createSocketMiddleware(socket),
|
||||
commands
|
||||
),
|
||||
window.devToolsExtension ? window.devToolsExtension() : f => f
|
||||
)(createStore);
|
||||
|
||||
return finalCreateStore(reducer, initialState);
|
||||
}
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
import { createStore, applyMiddleware, compose } from 'redux';
|
||||
import thunk from 'redux-thunk';
|
||||
import { syncHistory } from 'react-router-redux';
|
||||
import reducer from '../reducers';
|
||||
import createSocketMiddleware from '../middleware/socket';
|
||||
import commands from '../commands';
|
||||
import DevTools from '../containers/DevTools';
|
||||
|
||||
export default function configureStore(socket, history, initialState) {
|
||||
const reduxRouterMiddleware = syncHistory(history);
|
||||
|
||||
const finalCreateStore = compose(
|
||||
applyMiddleware(
|
||||
reduxRouterMiddleware,
|
||||
thunk,
|
||||
createSocketMiddleware(socket),
|
||||
commands
|
||||
),
|
||||
DevTools.instrument()
|
||||
)(createStore);
|
||||
|
||||
const store = finalCreateStore(reducer, initialState);
|
||||
|
||||
reduxRouterMiddleware.listenForReplays(store);
|
||||
|
||||
if (module.hot) {
|
||||
module.hot.accept('../reducers', () => {
|
||||
store.replaceReducer(require('../reducers').default);
|
||||
});
|
||||
}
|
||||
|
||||
return store;
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
import { createStore, applyMiddleware } from 'redux';
|
||||
import thunk from 'redux-thunk';
|
||||
import { syncHistory } from 'react-router-redux';
|
||||
import reducer from '../reducers';
|
||||
import createSocketMiddleware from '../middleware/socket';
|
||||
import commands from '../commands';
|
||||
|
||||
export default function configureStore(socket, history, initialState) {
|
||||
const finalCreateStore = applyMiddleware(
|
||||
syncHistory(history),
|
||||
thunk,
|
||||
createSocketMiddleware(socket),
|
||||
commands
|
||||
)(createStore);
|
||||
|
||||
return finalCreateStore(reducer, initialState);
|
||||
}
|
|
@ -8,6 +8,8 @@ const autolinker = new Autolinker({
|
|||
if (match.getType() === 'url') {
|
||||
return <a target="_blank" href={match.getAnchorHref()}>{match.getAnchorText()}</a>;
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
React
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue