summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2016-02-26 09:49:29 -0800
committer=Corey Hulen <corey@hulen.com>2016-02-26 09:49:29 -0800
commita0cc464c973fe0b2ca8aa1fa386656435bdbfbec (patch)
tree77646ea56732d30d87e975b9ccccae273f6a1915
parentce5ea641aafa269aad44d1d3dd31db30e8fc2b04 (diff)
downloadchat-a0cc464c973fe0b2ca8aa1fa386656435bdbfbec.tar.gz
chat-a0cc464c973fe0b2ca8aa1fa386656435bdbfbec.tar.bz2
chat-a0cc464c973fe0b2ca8aa1fa386656435bdbfbec.zip
PLT-2030 fixing error handling
-rw-r--r--web/react/components/error_bar.jsx16
-rw-r--r--web/react/components/textbox.jsx4
-rw-r--r--web/react/stores/error_store.jsx20
-rw-r--r--web/react/stores/socket_store.jsx8
-rw-r--r--web/react/utils/client.jsx13
5 files changed, 25 insertions, 36 deletions
diff --git a/web/react/components/error_bar.jsx b/web/react/components/error_bar.jsx
index f04185b46..9a114c544 100644
--- a/web/react/components/error_bar.jsx
+++ b/web/react/components/error_bar.jsx
@@ -38,25 +38,9 @@ export default class ErrorBar extends React.Component {
return false;
}
- if (s.connErrorCount && s.connErrorCount >= 1 && s.connErrorCount < 7) {
- return false;
- }
-
return true;
}
- isConnectionError(s) {
- if (!s.connErrorCount || s.connErrorCount === 0) {
- return false;
- }
-
- if (s.connErrorCount > 7) {
- return true;
- }
-
- return false;
- }
-
componentWillMount() {
if (global.window.mm_config.SendEmailNotifications === 'false') {
ErrorStore.storeLastError({message: this.props.intl.formatMessage(messages.preview)});
diff --git a/web/react/components/textbox.jsx b/web/react/components/textbox.jsx
index ec299087d..23ecfb57b 100644
--- a/web/react/components/textbox.jsx
+++ b/web/react/components/textbox.jsx
@@ -59,9 +59,9 @@ export default class Textbox extends React.Component {
}
onRecievedError() {
- const errorState = ErrorStore.getLastError();
+ const errorCount = ErrorStore.getConnectionErrorCount();
- if (errorState && errorState.connErrorCount > 0) {
+ if (errorCount > 0) {
this.setState({connection: 'bad-connection'});
} else {
this.setState({connection: ''});
diff --git a/web/react/stores/error_store.jsx b/web/react/stores/error_store.jsx
index 5afcefd12..6928b1e59 100644
--- a/web/react/stores/error_store.jsx
+++ b/web/react/stores/error_store.jsx
@@ -18,7 +18,6 @@ class ErrorStoreClass extends EventEmitter {
this.emitChange = this.emitChange.bind(this);
this.addChangeListener = this.addChangeListener.bind(this);
this.removeChangeListener = this.removeChangeListener.bind(this);
- this.handledError = this.handledError.bind(this);
this.getLastError = this.getLastError.bind(this);
this.storeLastError = this.storeLastError.bind(this);
}
@@ -35,10 +34,6 @@ class ErrorStoreClass extends EventEmitter {
this.removeListener(CHANGE_EVENT, callback);
}
- handledError() {
- BrowserStore.removeItem('last_error');
- }
-
getLastError() {
return BrowserStore.getItem('last_error');
}
@@ -47,8 +42,23 @@ class ErrorStoreClass extends EventEmitter {
BrowserStore.setItem('last_error', error);
}
+ getConnectionErrorCount() {
+ var count = BrowserStore.getItem('last_error_conn');
+
+ if (count == null) {
+ return 0;
+ }
+
+ return count;
+ }
+
+ setConnectionErrorCount(count) {
+ BrowserStore.setItem('last_error_conn', count);
+ }
+
clearLastError() {
BrowserStore.removeItem('last_error');
+ BrowserStore.removeItem('last_error_conn');
}
}
diff --git a/web/react/stores/socket_store.jsx b/web/react/stores/socket_store.jsx
index efb57e226..46f322e5f 100644
--- a/web/react/stores/socket_store.jsx
+++ b/web/react/stores/socket_store.jsx
@@ -66,7 +66,7 @@ class SocketStoreClass extends EventEmitter {
console.log('websocket re-established connection'); //eslint-disable-line no-console
if (ErrorStore.getLastError()) {
- ErrorStore.storeLastError(null);
+ ErrorStore.clearLastError();
ErrorStore.emitChange();
}
@@ -86,7 +86,11 @@ class SocketStoreClass extends EventEmitter {
this.failCount = this.failCount + 1;
- ErrorStore.storeLastError({connErrorCount: this.failCount, message: this.translations.socketError});
+ if (this.failCount > 7) {
+ ErrorStore.storeLastError({message: this.translations.socketError});
+ }
+
+ ErrorStore.setConnectionErrorCount(this.failCount);
ErrorStore.emitChange();
setTimeout(
diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx
index 81bdb7293..2d0377e72 100644
--- a/web/react/utils/client.jsx
+++ b/web/react/utils/client.jsx
@@ -28,16 +28,7 @@ function handleError(methodName, xhr, status, err) {
msg = 'error in ' + methodName + ' status=' + status + ' statusCode=' + xhr.status + ' err=' + err;
if (xhr.status === 0) {
- let errorCount = 1;
- const oldError = ErrorStore.getLastError();
- let connectError = 'There appears to be a problem with your internet connection';
-
- if (oldError && oldError.connErrorCount) {
- errorCount += oldError.connErrorCount;
- connectError = 'Please check connection, Mattermost unreachable. If issue persists, ask administrator to check WebSocket port.';
- }
-
- e = {message: connectError, connErrorCount: errorCount};
+ e = {message: 'There appears to be a problem with your internet connection'};
} else {
e = {message: 'We received an unexpected status code from the server (' + xhr.status + ')'};
}
@@ -279,7 +270,7 @@ export function logout() {
var currentTeamUrl = TeamStore.getCurrentTeamUrl();
BrowserStore.signalLogout();
BrowserStore.clear();
- ErrorStore.storeLastError(null);
+ ErrorStore.clearLastError();
window.location.href = currentTeamUrl + '/logout';
}