Open dm tab on /msg

This commit is contained in:
Ken-Håvard Lieng 2020-05-06 04:50:27 +02:00
parent 8305dd561d
commit 7d97d10e76
3 changed files with 114 additions and 110 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,10 @@
import { COMMAND } from 'state/actions';
import { join, part, invite, kick, setTopic } from 'state/channels';
import { sendMessage, raw } from 'state/messages';
import { openPrivateChat } from 'state/privateChats';
import { setNick, disconnect, whois, away } from 'state/servers';
import { select } from 'state/tab';
import { find } from 'utils';
import { find, isChannel } from 'utils';
import createCommandMiddleware, {
beforeHandler,
notFoundHandler
@ -45,10 +46,10 @@ export default createCommandMiddleware(COMMAND, {
}
},
part({ dispatch, server, channel, isChannel }, partChannel) {
part({ dispatch, server, channel, inChannel }, partChannel) {
if (partChannel) {
dispatch(part([partChannel], server));
} else if (isChannel) {
} else if (inChannel) {
dispatch(part([channel], server));
} else {
return error('This is not a channel');
@ -98,6 +99,9 @@ export default createCommandMiddleware(COMMAND, {
const msg = message.join(' ');
if (msg !== '') {
dispatch(sendMessage(message.join(' '), target, server));
if (!isChannel(target)) {
dispatch(openPrivateChat(server, target));
}
dispatch(select(server, target));
} else {
return error('Messages can not be empty');
@ -117,8 +121,8 @@ export default createCommandMiddleware(COMMAND, {
}
},
invite({ dispatch, server, channel, isChannel }, user, inviteChannel) {
if (!inviteChannel && !isChannel) {
invite({ dispatch, server, channel, inChannel }, user, inviteChannel) {
if (!inviteChannel && !inChannel) {
return error('This is not a channel');
}
@ -131,8 +135,8 @@ export default createCommandMiddleware(COMMAND, {
}
},
kick({ dispatch, server, channel, isChannel }, user) {
if (!isChannel) {
kick({ dispatch, server, channel, inChannel }, user) {
if (!inChannel) {
return error('This is not a channel');
}

View File

@ -5,7 +5,7 @@ export const beforeHandler = '_before';
export const notFoundHandler = 'commandNotFound';
function createContext({ dispatch, getState }, { server, channel }) {
return { dispatch, getState, server, channel, isChannel: isChannel(channel) };
return { dispatch, getState, server, channel, inChannel: isChannel(channel) };
}
// TODO: Pull this out as convenience action