Use the AsyncClient call 'updateLastViewedAt' as a way of checking for inet connectivity immediately after clearning yellow bar after user has typed 5 characters

Этот коммит содержится в:
Reed Garmsen
2015-07-09 17:49:02 -07:00
родитель 80f9ebadef
Коммит 56f369cfd1
2 изменённых файлов: 16 добавлений и 10 удалений

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

@@ -9,6 +9,7 @@ var MsgTyping = require('./msg_typing.jsx');
var MentionList = require('./mention_list.jsx'); var MentionList = require('./mention_list.jsx');
var CommandList = require('./command_list.jsx'); var CommandList = require('./command_list.jsx');
var ErrorStore = require('../stores/error_store.jsx'); var ErrorStore = require('../stores/error_store.jsx');
var AsyncClient = require('../utils/async_client.jsx');
var utils = require('../utils/utils.jsx'); var utils = require('../utils/utils.jsx');
var Constants = require('../utils/constants.jsx'); var Constants = require('../utils/constants.jsx');
@@ -32,7 +33,6 @@ module.exports = React.createClass({
componentDidMount: function() { componentDidMount: function() {
PostStore.addAddMentionListener(this._onChange); PostStore.addAddMentionListener(this._onChange);
ErrorStore.addChangeListener(this._onError); ErrorStore.addChangeListener(this._onError);
//SocketStore.addChangeListener(this._onSocketChange);
this.resize(); this.resize();
this.processMentions(); this.processMentions();
@@ -53,16 +53,9 @@ module.exports = React.createClass({
this.setState({ connection: " bad-connection" }); this.setState({ connection: " bad-connection" });
} }
else { else {
console.log("Logged the error correctly");
this.setState({ connection: "" }); this.setState({ connection: "" });
} }
}, },
/*_onSocketChange: function() {
if (SocketStore.isSocketClosed())
this.setState({ connection: " bad-connection" });
else
this.setState({ connection: "" });
},*/
componentDidUpdate: function() { componentDidUpdate: function() {
if (this.caret >= 0) { if (this.caret >= 0) {
utils.setCaretPosition(this.refs.message.getDOMNode(), this.caret) utils.setCaretPosition(this.refs.message.getDOMNode(), this.caret)
@@ -88,7 +81,7 @@ module.exports = React.createClass({
this.resize(); this.resize();
}, },
getInitialState: function() { getInitialState: function() {
return { mentionText: '-1', mentions: [], connection: "" }; return { mentionText: '-1', mentions: [], connection: "", numPresses: 0 };
}, },
updateMentionTab: function(mentionText, excludeList) { updateMentionTab: function(mentionText, excludeList) {
var self = this; var self = this;
@@ -120,6 +113,19 @@ module.exports = React.createClass({
handleKeyPress: function(e) { handleKeyPress: function(e) {
var text = this.refs.message.getDOMNode().value; 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) { if (!this.refs.commands.isEmpty() && text.indexOf("/") == 0 && e.which==13) {
this.refs.commands.addFirstCommand(); this.refs.commands.addFirstCommand();
e.preventDefault(); e.preventDefault();

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

@@ -31,7 +31,7 @@ var ErrorStore = assign({}, EventEmitter.prototype, {
getLastError: function() { getLastError: function() {
var error = null; var error = null;
try { try {
error = JSON.parse(BrowserStore.last_error); error = JSON.parse(BrowserStore.getItem("last_error"));
} }
catch (err) { catch (err) {
} }