summaryrefslogtreecommitdiffstats
path: root/webapp/components/create_post.jsx
diff options
context:
space:
mode:
authorDavid Lu <david.lu@hotmail.com>2016-06-02 15:43:00 -0700
committerenahum <nahumhbl@gmail.com>2016-06-02 19:43:00 -0300
commit2f7540e174dce808dc642c42d85151238c352e5d (patch)
treeb409af63de15d0f565747dfcd75c58b76d0dff96 /webapp/components/create_post.jsx
parent8165f5d91fab1730fcef4832e4bfbe0323d911e0 (diff)
downloadchat-2f7540e174dce808dc642c42d85151238c352e5d.tar.gz
chat-2f7540e174dce808dc642c42d85151238c352e5d.tar.bz2
chat-2f7540e174dce808dc642c42d85151238c352e5d.zip
PLT-3028 Added CTRL+/ to show shortcuts (#3181)
* Added CTRL / to show shortcuts * Simplified code
Diffstat (limited to 'webapp/components/create_post.jsx')
-rw-r--r--webapp/components/create_post.jsx23
1 files changed, 22 insertions, 1 deletions
diff --git a/webapp/components/create_post.jsx b/webapp/components/create_post.jsx
index cdcaacbf3..5904d2f29 100644
--- a/webapp/components/create_post.jsx
+++ b/webapp/components/create_post.jsx
@@ -13,6 +13,7 @@ import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
import * as GlobalActions from 'actions/global_actions.jsx';
import Client from 'utils/web_client.jsx';
import * as Utils from 'utils/utils.jsx';
+import * as ChannelActions from 'actions/channel_actions.jsx';
import ChannelStore from 'stores/channel_store.jsx';
import PostStore from 'stores/post_store.jsx';
@@ -69,6 +70,7 @@ class CreatePost extends React.Component {
this.focusTextbox = this.focusTextbox.bind(this);
this.showPostDeletedModal = this.showPostDeletedModal.bind(this);
this.hidePostDeletedModal = this.hidePostDeletedModal.bind(this);
+ this.showShortcuts = this.showShortcuts.bind(this);
PostStore.clearDraftUploads();
@@ -129,7 +131,7 @@ class CreatePost extends React.Component {
this.setState({submitting: true, serverError: null});
this.setState({lastMessage: this.state.messageText});
if (post.message.indexOf('/') === 0) {
- Client.executeCommand(
+ ChannelActions.executeCommand(
this.state.channelId,
post.message,
false,
@@ -311,6 +313,7 @@ class CreatePost extends React.Component {
PreferenceStore.addChangeListener(this.onPreferenceChange);
this.focusTextbox();
+ document.addEventListener('keydown', this.showShortcuts);
}
componentDidUpdate(prevProps, prevState) {
if (prevState.channelId !== this.state.channelId) {
@@ -320,6 +323,24 @@ class CreatePost extends React.Component {
componentWillUnmount() {
ChannelStore.removeChangeListener(this.onChange);
PreferenceStore.removeChangeListener(this.onPreferenceChange);
+ document.removeEventListener('keydown', this.showShortcuts);
+ }
+ showShortcuts(e) {
+ if ((e.ctrlKey || e.metaKey) && e.keyCode === Constants.KeyCodes.FORWARD_SLASH) {
+ e.preventDefault();
+ ChannelActions.executeCommand(
+ this.state.channelId,
+ '/shortcuts ',
+ false,
+ null,
+ (err) => {
+ this.setState({
+ serverError: err.message,
+ submitting: false
+ });
+ }
+ );
+ }
}
onChange() {
const channelId = ChannelStore.getCurrentId();