Improve error routing, fix dm tab not opening

This commit is contained in:
Ken-Håvard Lieng 2020-06-21 05:13:38 +02:00
parent 1c996822cd
commit ca23b3ded8
4 changed files with 62 additions and 51 deletions

View file

@ -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)
);