[deploy] Add functionality to /connect (#7264)

This commit is contained in:
Ben Halpern 2020-04-13 17:27:32 -04:00 committed by GitHub
parent 7103b406ad
commit dc76277f0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -560,7 +560,8 @@ export default class Chat extends Component {
};
handleMessageSubmit = (message) => {
const { activeChannelId } = this.state;
const { activeChannelId, activeContent } = this.state;
scrollToBottom();
// should check if user has the privilege
if (message.startsWith('/code')) {
this.setActiveContentState(activeChannelId, { type_of: 'code_editor' });
@ -580,6 +581,30 @@ export default class Chat extends Component {
path: '/new',
type_of: 'article',
});
} else if (message.startsWith('/search')) {
this.setActiveContentState(activeChannelId, {
type_of: 'loading-post',
});
this.setActiveContent({
path: '/search?q=' + message.replace('/search ', ''),
type_of: 'article',
});
} else if (message.startsWith('/s ')) {
this.setActiveContentState(activeChannelId, {
type_of: 'loading-post',
});
this.setActiveContent({
path: '/search?q=' + message.replace('/s ', ''),
type_of: 'article',
});
} else if (message.startsWith('/')) {
this.setActiveContentState(activeChannelId, {
type_of: 'loading-post',
});
this.setActiveContent({
path: message,
type_of: 'article',
});
} else if (message.startsWith('/github')) {
const args = message.split('/github ')[1].trim();
this.setActiveContentState(activeChannelId, { type_of: 'github', args });
@ -691,6 +716,7 @@ export default class Chat extends Component {
handleSuccess = (response) => {
const { activeChannelId } = this.state;
scrollToBottom();
if (response.status === 'success') {
if (response.message.temp_id) {
this.setState(({ messages }) => {