Added errorchange listener to textbox that detects if inet is not connected. Still do not have reliable way of checking if inet has reconnected

Этот коммит содержится в:
Reed Garmsen
2015-07-07 11:22:58 -07:00
родитель eddf43e133
Коммит 80f9ebadef
4 изменённых файлов: 38 добавлений и 10 удалений

Просмотреть файл

@@ -9,7 +9,7 @@ var ActionTypes = Constants.ActionTypes;
function getStateFromStores() {
var error = ErrorStore.getLastError();
if (error) {
if (error && error.message !== "There appears to be a problem with your internet connection") {
return { message: error.message };
} else {
return { message: null };

Просмотреть файл

@@ -8,11 +8,22 @@ var SocketStore = require('../stores/socket_store.jsx');
var MsgTyping = require('./msg_typing.jsx');
var MentionList = require('./mention_list.jsx');
var CommandList = require('./command_list.jsx');
var ErrorStore = require('../stores/error_store.jsx');
var utils = require('../utils/utils.jsx');
var Constants = require('../utils/constants.jsx');
var ActionTypes = Constants.ActionTypes;
function getStateFromStores() {
var error = ErrorStore.getLastError();
if (error) {
return { message: error.message };
} else {
return { message: null };
}
}
module.exports = React.createClass({
caret: -1,
addedMention: false,
@@ -20,6 +31,8 @@ module.exports = React.createClass({
mentions: [],
componentDidMount: function() {
PostStore.addAddMentionListener(this._onChange);
ErrorStore.addChangeListener(this._onError);
//SocketStore.addChangeListener(this._onSocketChange);
this.resize();
this.processMentions();
@@ -27,11 +40,29 @@ module.exports = React.createClass({
},
componentWillUnmount: function() {
PostStore.removeAddMentionListener(this._onChange);
ErrorStore.removeChangeListener(this._onError);
},
_onChange: function(id, username) {
if (id !== this.props.id) return;
this.addMention(username);
},
_onError: function() {
var errorState = getStateFromStores();
if (errorState.message === "There appears to be a problem with your internet connection") {
this.setState({ connection: " bad-connection" });
}
else {
console.log("Logged the error correctly");
this.setState({ connection: "" });
}
},
/*_onSocketChange: function() {
if (SocketStore.isSocketClosed())
this.setState({ connection: " bad-connection" });
else
this.setState({ connection: "" });
},*/
componentDidUpdate: function() {
if (this.caret >= 0) {
utils.setCaretPosition(this.refs.message.getDOMNode(), this.caret)
@@ -57,7 +88,7 @@ module.exports = React.createClass({
this.resize();
},
getInitialState: function() {
return { mentionText: '-1', mentions: [] };
return { mentionText: '-1', mentions: [], connection: "" };
},
updateMentionTab: function(mentionText, excludeList) {
var self = this;
@@ -287,7 +318,7 @@ module.exports = React.createClass({
<div ref="wrapper" className="textarea-wrapper">
<CommandList ref='commands' addCommand={this.addCommand} channelId={this.props.channelId} />
<div className="form-control textarea-div" ref="textdiv"/>
<textarea id={this.props.id} ref="message" className="form-control custom-textarea" spellCheck="true" autoComplete="off" autoCorrect="off" rows="1" placeholder={this.props.createMessage} value={this.props.messageText} onInput={this.handleChange} onChange={this.handleChange} onKeyPress={this.handleKeyPress} onKeyDown={this.handleKeyDown} onScroll={this.scroll} onFocus={this.handleFocus} onBlur={this.handleBlur} onPaste={this.handlePaste} />
<textarea id={this.props.id} ref="message" className={"form-control custom-textarea" + this.state.connection} spellCheck="true" autoComplete="off" autoCorrect="off" rows="1" placeholder={this.props.createMessage} value={this.props.messageText} onInput={this.handleChange} onChange={this.handleChange} onKeyPress={this.handleKeyPress} onKeyDown={this.handleKeyDown} onScroll={this.scroll} onFocus={this.handleFocus} onBlur={this.handleBlur} onPaste={this.handlePaste} />
</div>
);
}

Просмотреть файл

@@ -15,13 +15,6 @@ var ActionTypes = Constants.ActionTypes;
var callTracker = {};
var dispatchError = function(err, method) {
if (err.message === "There appears to be a problem with your internet connection") {
//Need to communicate this fact to textbox and cause it to change color
return;
}
AppDispatcher.handleServerAction({
type: ActionTypes.RECIEVED_ERROR,
err: err,

Просмотреть файл

@@ -11,6 +11,10 @@
min-height:36px;
}
.bad-connection {
background-color: rgb(255, 255, 172);
}
.textarea-div {
white-space:pre-wrap;
word-wrap:normal;