summaryrefslogtreecommitdiffstats
path: root/web/react/components/edit_post_modal.jsx
diff options
context:
space:
mode:
authorFlorian Orben <florian.orben@gmail.com>2015-10-15 02:13:48 +0200
committerFlorian Orben <florian.orben@gmail.com>2015-10-15 21:25:31 +0200
commit551b07960ed8ec36c24341f96f2b06fee25ceab3 (patch)
tree1b05af0c4cb1b111d935aa8fbc6cb3629b7c8742 /web/react/components/edit_post_modal.jsx
parentc890e21cefe135a74a4a7235b704e7af95decc5c (diff)
downloadchat-551b07960ed8ec36c24341f96f2b06fee25ceab3.tar.gz
chat-551b07960ed8ec36c24341f96f2b06fee25ceab3.tar.bz2
chat-551b07960ed8ec36c24341f96f2b06fee25ceab3.zip
PLT-74: Enable Up Arrow keyboard shortcut to edit your last message
Diffstat (limited to 'web/react/components/edit_post_modal.jsx')
-rw-r--r--web/react/components/edit_post_modal.jsx22
1 files changed, 22 insertions, 0 deletions
diff --git a/web/react/components/edit_post_modal.jsx b/web/react/components/edit_post_modal.jsx
index 3dbff18cb..38d31d66f 100644
--- a/web/react/components/edit_post_modal.jsx
+++ b/web/react/components/edit_post_modal.jsx
@@ -5,6 +5,7 @@ var Client = require('../utils/client.jsx');
var AsyncClient = require('../utils/async_client.jsx');
var Textbox = require('./textbox.jsx');
var BrowserStore = require('../stores/browser_store.jsx');
+var PostStore = require('../stores/post_store.jsx');
export default class EditPostModal extends React.Component {
constructor() {
@@ -14,6 +15,7 @@ export default class EditPostModal extends React.Component {
this.handleEditInput = this.handleEditInput.bind(this);
this.handleEditKeyPress = this.handleEditKeyPress.bind(this);
this.handleUserInput = this.handleUserInput.bind(this);
+ this.handleEditPostEvent = this.handleEditPostEvent.bind(this);
this.state = {editText: '', title: '', post_id: '', channel_id: '', comments: 0, refocusId: ''};
}
@@ -59,6 +61,18 @@ export default class EditPostModal extends React.Component {
handleUserInput(e) {
this.setState({editText: e.target.value});
}
+ handleEditPostEvent(options) {
+ this.setState({
+ editText: options.message || '',
+ title: options.title || '',
+ post_id: options.postId || '',
+ channel_id: options.channelId || '',
+ comments: options.comments || 0,
+ refocusId: options.refocusId || ''
+ });
+
+ $(React.findDOMNode(this.refs.modal)).modal('show');
+ }
componentDidMount() {
var self = this;
@@ -68,12 +82,20 @@ export default class EditPostModal extends React.Component {
$(ReactDOM.findDOMNode(this.refs.modal)).on('show.bs.modal', function onShow(e) {
var button = e.relatedTarget;
+ if (!button) {
+ return;
+ }
self.setState({editText: $(button).attr('data-message'), title: $(button).attr('data-title'), channel_id: $(button).attr('data-channelid'), post_id: $(button).attr('data-postid'), comments: $(button).attr('data-comments'), refocusId: $(button).attr('data-refoucsid')});
});
$(ReactDOM.findDOMNode(this.refs.modal)).on('shown.bs.modal', function onShown() {
self.refs.editbox.resize();
});
+
+ PostStore.addEditPostListener(this.handleEditPostEvent);
+ }
+ componentWillUnmount() {
+ PostStore.removeEditPostListener(this.handleEditPostEvent);
}
render() {
var error = (<div className='form-group'><br /></div>);