Switch to redux and webpack
This commit is contained in:
parent
b247287075
commit
e389454535
97 changed files with 2722 additions and 2656 deletions
29
client/src/js/reducers/privateChats.js
Normal file
29
client/src/js/reducers/privateChats.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
import { Set, Map } from 'immutable';
|
||||
import createReducer from '../util/createReducer';
|
||||
import * as actions from '../actions';
|
||||
|
||||
function open(state, server, nick) {
|
||||
return state.update(server, Set(), chats => chats.add(nick));
|
||||
}
|
||||
|
||||
export default createReducer(Map(), {
|
||||
[actions.OPEN_PRIVATE_CHAT](state, action) {
|
||||
return open(state, action.server, action.nick);
|
||||
},
|
||||
|
||||
[actions.CLOSE_PRIVATE_CHAT](state, action) {
|
||||
return state.update(action.server, chats => chats.delete(action.nick));
|
||||
},
|
||||
|
||||
[actions.SOCKET_PM](state, action) {
|
||||
if (action.from.indexOf('.') === -1) {
|
||||
return open(state, action.server, action.from);
|
||||
}
|
||||
|
||||
return state;
|
||||
},
|
||||
|
||||
[actions.DISCONNECT](state, action) {
|
||||
return state.delete(action.server);
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue