Improve error routing, fix dm tab not opening
This commit is contained in:
parent
1c996822cd
commit
ca23b3ded8
File diff suppressed because one or more lines are too long
@ -112,6 +112,18 @@ export default function handleSocket({
|
||||
},
|
||||
|
||||
error({ network, target, message }) {
|
||||
const state = getState();
|
||||
const tab = state.tab.selected;
|
||||
|
||||
if (network === tab.network) {
|
||||
// Print it in the current channel if the error happened on
|
||||
// the current network
|
||||
target = tab.name;
|
||||
} else if (!state.channels[network]?.[target]) {
|
||||
// Print it the network tab if the target does not exist
|
||||
target = null;
|
||||
}
|
||||
|
||||
dispatch(
|
||||
addMessage({ content: message, type: 'error' }, network, target)
|
||||
);
|
||||
|
@ -1,4 +1,5 @@
|
||||
import sortBy from 'lodash/sortBy';
|
||||
import { isChannel } from 'utils';
|
||||
import createReducer from 'utils/createReducer';
|
||||
import { updateSelection } from './tab';
|
||||
import * as actions from './actions';
|
||||
@ -39,9 +40,10 @@ export default createReducer(
|
||||
});
|
||||
},
|
||||
|
||||
[actions.socket.PM](state, action) {
|
||||
if (action.from.indexOf('.') === -1) {
|
||||
open(state, action.network, action.from);
|
||||
[actions.ADD_MESSAGE](state, { message }) {
|
||||
const { network, from } = message;
|
||||
if (from !== network && !isChannel(from)) {
|
||||
open(state, network, from);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -105,19 +105,16 @@ func (i *ircHandler) run() {
|
||||
}
|
||||
|
||||
func (i *ircHandler) dispatchMessage(msg *irc.Message) {
|
||||
if msg.Command[0] == '4' && !isExcludedError(msg.Command) {
|
||||
if (msg.Command[0] == '4' || msg.Command[0] == '5') &&
|
||||
len(msg.Params) > 1 &&
|
||||
!isExcludedError(msg.Command) {
|
||||
err := IRCError{
|
||||
Network: i.client.Host(),
|
||||
Message: msg.LastParam(),
|
||||
Message: strings.Join(msg.Params[1:], " "),
|
||||
}
|
||||
|
||||
if len(msg.Params) > 2 {
|
||||
for i := 1; i < len(msg.Params); i++ {
|
||||
if isChannel(msg.Params[i]) {
|
||||
err.Target = msg.Params[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
if isChannel(msg.Params[1]) {
|
||||
err.Target = msg.Params[1]
|
||||
}
|
||||
|
||||
i.state.sendJSON("error", err)
|
||||
|
Loading…
Reference in New Issue
Block a user