Push up instantiation of TabComplete to RoomView
RoomView is the parent component which creates MessageComposer AND the status bar. By making RoomView instantiate TabComplete we can scope instances correctly rather than relying on singleton behaviour through dispatches. This also makes communication between status bar and the MessageComposer infinitely easier since they are now sharing the same TabComplete object.
This commit is contained in:
parent
c6d02b2c26
commit
26dc3cc553
3 changed files with 40 additions and 12 deletions
|
@ -31,7 +31,6 @@ var MatrixClientPeg = require("../../../MatrixClientPeg");
|
|||
var SlashCommands = require("../../../SlashCommands");
|
||||
var Modal = require("../../../Modal");
|
||||
var CallHandler = require('../../../CallHandler');
|
||||
var TabComplete = require("../../../TabComplete");
|
||||
var sdk = require('../../../index');
|
||||
|
||||
var dis = require("../../../dispatcher");
|
||||
|
@ -65,6 +64,10 @@ function mdownToHtml(mdown) {
|
|||
module.exports = React.createClass({
|
||||
displayName: 'MessageComposer',
|
||||
|
||||
propTypes: {
|
||||
tabComplete: React.PropTypes.any
|
||||
},
|
||||
|
||||
componentWillMount: function() {
|
||||
this.oldScrollHeight = 0;
|
||||
this.markdownEnabled = MARKDOWN_ENABLED;
|
||||
|
@ -168,14 +171,9 @@ module.exports = React.createClass({
|
|||
this.props.room.roomId
|
||||
);
|
||||
this.resizeInput();
|
||||
|
||||
// xchat-style tab complete, add a colon if tab
|
||||
// completing at the start of the text
|
||||
this._tabComplete = new TabComplete({
|
||||
textArea: this.refs.textarea,
|
||||
startingWordSuffix: ": ",
|
||||
wordSuffix: " "
|
||||
});
|
||||
if (this.props.tabComplete) {
|
||||
this.props.tabComplete.setTextArea(this.refs.textarea);
|
||||
}
|
||||
},
|
||||
|
||||
componentWillUnmount: function() {
|
||||
|
@ -233,7 +231,9 @@ module.exports = React.createClass({
|
|||
return m.name || m.userId;
|
||||
});
|
||||
}
|
||||
this._tabComplete.setCompletionList(memberList);
|
||||
if (this.props.tabComplete) {
|
||||
this.props.tabComplete.setCompletionList(memberList);
|
||||
}
|
||||
}
|
||||
else if (ev.keyCode === KeyCode.UP) {
|
||||
var input = this.refs.textarea.value;
|
||||
|
@ -253,7 +253,10 @@ module.exports = React.createClass({
|
|||
this.resizeInput();
|
||||
}
|
||||
}
|
||||
this._tabComplete.onKeyDown(ev);
|
||||
|
||||
if (this.props.tabComplete) {
|
||||
this.props.tabComplete.onKeyDown(ev);
|
||||
}
|
||||
|
||||
var self = this;
|
||||
setTimeout(function() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue