diff options
author | Reed Garmsen <rgarmsen2295@gmail.com> | 2015-07-09 18:17:40 -0700 |
---|---|---|
committer | Reed Garmsen <rgarmsen2295@gmail.com> | 2015-07-09 18:17:40 -0700 |
commit | eb99363169902574d41e8037ea0d2de4770dcb5a (patch) | |
tree | c70efaef65c8fbae7633d882f1002ff7c152cb60 /web | |
parent | 7f0d070bf107502a96c5271cc2bc939bd115362a (diff) | |
download | chat-eb99363169902574d41e8037ea0d2de4770dcb5a.tar.gz chat-eb99363169902574d41e8037ea0d2de4770dcb5a.tar.bz2 chat-eb99363169902574d41e8037ea0d2de4770dcb5a.zip |
Changed method again this time to a timer based system so that when inet does come back the yellow tinge goes away automatically not on user input
Diffstat (limited to 'web')
-rw-r--r-- | web/react/components/textbox.jsx | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/web/react/components/textbox.jsx b/web/react/components/textbox.jsx index 16219156d..161b30646 100644 --- a/web/react/components/textbox.jsx +++ b/web/react/components/textbox.jsx @@ -51,9 +51,35 @@ module.exports = React.createClass({ if (errorState.message === "There appears to be a problem with your internet connection") { this.setState({ connection: " bad-connection" }); + var timerInterrupt = window.setInterval(this._onTimerInterrupt, 5000); + this.setState({ timerInterrupt: timerInterrupt }); } else { this.setState({ connection: "" }); + if (this.state.timerInterrupt != null) { + window.clearInterval(this.state.timerInterrupt); + this.setState({ timerInterrupt: null }); + } + } + }, + _onTimerInterrupt: function() { + //Since these should only happen when you have no connection and slightly briefly after any + //performance hit should not matter + if (this.state.connection === " bad-connection") { + AppDispatcher.handleServerAction({ + type: ActionTypes.RECIEVED_ERROR, + err: null + }); + this.setState({ numPresses: 0 }); + + + window.clearInterval(this.state.timerInterrupt); + this.setState({ timerInterrupt: null }); + AsyncClient.updateLastViewedAt(); + } + else { + window.clearInterval(this.state.timerInterrupt); + this.setState({ timerInterrupt: null }); } }, componentDidUpdate: function() { @@ -81,7 +107,7 @@ module.exports = React.createClass({ this.resize(); }, getInitialState: function() { - return { mentionText: '-1', mentions: [], connection: "", numPresses: 0 }; + return { mentionText: '-1', mentions: [], connection: "", timerInterrupt: null }; }, updateMentionTab: function(mentionText, excludeList) { var self = this; @@ -113,21 +139,6 @@ module.exports = React.createClass({ handleKeyPress: function(e) { var text = this.refs.message.getDOMNode().value; - //Since these should only happen when you have no connection and slightly briefly after any - //performance hit should not matter - if (this.state.connection === " bad-connection" && this.state.numPresses > 5) { - AppDispatcher.handleServerAction({ - type: ActionTypes.RECIEVED_ERROR, - err: null - }); - this.setState({ numPresses: 0 }); - - AsyncClient.updateLastViewedAt(); - } - else if (this.state.connection === " bad-connection") { - this.setState({ numPresses: this.state.numPresses + 1 }); - } - if (!this.refs.commands.isEmpty() && text.indexOf("/") == 0 && e.which==13) { this.refs.commands.addFirstCommand(); e.preventDefault(); |