From 56f369cfd1c8a480a1e70a10564670153dae2ff2 Mon Sep 17 00:00:00 2001 From: Reed Garmsen Date: Thu, 9 Jul 2015 17:49:02 -0700 Subject: Use the AsyncClient call 'updateLastViewedAt' as a way of checking for inet connectivity immediately after clearning yellow bar after user has typed 5 characters --- web/react/components/textbox.jsx | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'web/react/components/textbox.jsx') diff --git a/web/react/components/textbox.jsx b/web/react/components/textbox.jsx index 227d61e3f..db28fe3ab 100644 --- a/web/react/components/textbox.jsx +++ b/web/react/components/textbox.jsx @@ -9,6 +9,7 @@ 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 AsyncClient = require('../utils/async_client.jsx'); var utils = require('../utils/utils.jsx'); var Constants = require('../utils/constants.jsx'); @@ -32,7 +33,6 @@ module.exports = React.createClass({ componentDidMount: function() { PostStore.addAddMentionListener(this._onChange); ErrorStore.addChangeListener(this._onError); - //SocketStore.addChangeListener(this._onSocketChange); this.resize(); this.processMentions(); @@ -53,16 +53,9 @@ module.exports = React.createClass({ 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) @@ -88,7 +81,7 @@ module.exports = React.createClass({ this.resize(); }, getInitialState: function() { - return { mentionText: '-1', mentions: [], connection: "" }; + return { mentionText: '-1', mentions: [], connection: "", numPresses: 0 }; }, updateMentionTab: function(mentionText, excludeList) { var self = this; @@ -120,6 +113,19 @@ module.exports = React.createClass({ handleKeyPress: function(e) { var text = this.refs.message.getDOMNode().value; + 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(); -- cgit v1.2.3-1-g7c22