Open dm tab on /msg
This commit is contained in:
parent
8305dd561d
commit
7d97d10e76
File diff suppressed because one or more lines are too long
@ -1,9 +1,10 @@
|
|||||||
import { COMMAND } from 'state/actions';
|
import { COMMAND } from 'state/actions';
|
||||||
import { join, part, invite, kick, setTopic } from 'state/channels';
|
import { join, part, invite, kick, setTopic } from 'state/channels';
|
||||||
import { sendMessage, raw } from 'state/messages';
|
import { sendMessage, raw } from 'state/messages';
|
||||||
|
import { openPrivateChat } from 'state/privateChats';
|
||||||
import { setNick, disconnect, whois, away } from 'state/servers';
|
import { setNick, disconnect, whois, away } from 'state/servers';
|
||||||
import { select } from 'state/tab';
|
import { select } from 'state/tab';
|
||||||
import { find } from 'utils';
|
import { find, isChannel } from 'utils';
|
||||||
import createCommandMiddleware, {
|
import createCommandMiddleware, {
|
||||||
beforeHandler,
|
beforeHandler,
|
||||||
notFoundHandler
|
notFoundHandler
|
||||||
@ -45,10 +46,10 @@ export default createCommandMiddleware(COMMAND, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
part({ dispatch, server, channel, isChannel }, partChannel) {
|
part({ dispatch, server, channel, inChannel }, partChannel) {
|
||||||
if (partChannel) {
|
if (partChannel) {
|
||||||
dispatch(part([partChannel], server));
|
dispatch(part([partChannel], server));
|
||||||
} else if (isChannel) {
|
} else if (inChannel) {
|
||||||
dispatch(part([channel], server));
|
dispatch(part([channel], server));
|
||||||
} else {
|
} else {
|
||||||
return error('This is not a channel');
|
return error('This is not a channel');
|
||||||
@ -98,6 +99,9 @@ export default createCommandMiddleware(COMMAND, {
|
|||||||
const msg = message.join(' ');
|
const msg = message.join(' ');
|
||||||
if (msg !== '') {
|
if (msg !== '') {
|
||||||
dispatch(sendMessage(message.join(' '), target, server));
|
dispatch(sendMessage(message.join(' '), target, server));
|
||||||
|
if (!isChannel(target)) {
|
||||||
|
dispatch(openPrivateChat(server, target));
|
||||||
|
}
|
||||||
dispatch(select(server, target));
|
dispatch(select(server, target));
|
||||||
} else {
|
} else {
|
||||||
return error('Messages can not be empty');
|
return error('Messages can not be empty');
|
||||||
@ -117,8 +121,8 @@ export default createCommandMiddleware(COMMAND, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
invite({ dispatch, server, channel, isChannel }, user, inviteChannel) {
|
invite({ dispatch, server, channel, inChannel }, user, inviteChannel) {
|
||||||
if (!inviteChannel && !isChannel) {
|
if (!inviteChannel && !inChannel) {
|
||||||
return error('This is not a channel');
|
return error('This is not a channel');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,8 +135,8 @@ export default createCommandMiddleware(COMMAND, {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
kick({ dispatch, server, channel, isChannel }, user) {
|
kick({ dispatch, server, channel, inChannel }, user) {
|
||||||
if (!isChannel) {
|
if (!inChannel) {
|
||||||
return error('This is not a channel');
|
return error('This is not a channel');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ export const beforeHandler = '_before';
|
|||||||
export const notFoundHandler = 'commandNotFound';
|
export const notFoundHandler = 'commandNotFound';
|
||||||
|
|
||||||
function createContext({ dispatch, getState }, { server, channel }) {
|
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
|
// TODO: Pull this out as convenience action
|
||||||
|
Loading…
Reference in New Issue
Block a user