Handle channel forwarding and errors better

This commit is contained in:
Ken-Håvard Lieng 2019-01-25 11:02:31 +01:00
parent 497934888c
commit f8e12f5938
15 changed files with 481 additions and 213 deletions

View file

@ -66,8 +66,10 @@ export const socket = createSocketActions([
'cert_fail',
'cert_success',
'channels',
'channel_forward',
'channel_search',
'connection_update',
'error',
'join',
'message',
'mode',

View file

@ -140,6 +140,11 @@ export default createReducer(
state[server][channel].users.push(createUser(user));
},
[actions.socket.CHANNEL_FORWARD](state, action) {
init(state, action.server, action.new);
delete state[action.server][action.old];
},
[actions.socket.PART](state, { server, channel, user }) {
if (state[server][channel]) {
removeUser(state[server][channel].users, user);
@ -230,16 +235,27 @@ export function join(channels, server) {
}
export function part(channels, server) {
return dispatch => {
dispatch({
return (dispatch, getState) => {
const action = {
type: actions.PART,
channels,
server,
socket: {
server
};
const state = getState().channels[server];
const joined = channels.filter(c => state[c] && state[c].joined);
if (joined.length > 0) {
action.socket = {
type: 'part',
data: { channels, server }
}
});
data: {
channels: joined,
server
}
};
}
dispatch(action);
dispatch(updateSelection());
};
}

View file

@ -140,6 +140,12 @@ export default createReducer(
channels.forEach(channel => delete state[server][channel]);
},
[actions.socket.CHANNEL_FORWARD](state, { server, old }) {
if (state[server]) {
delete state[server][old];
}
},
[actions.UPDATE_MESSAGE_HEIGHT](
state,
{ wrapWidth, charWidth, windowWidth }