summaryrefslogtreecommitdiffstats
path: root/web/react
diff options
context:
space:
mode:
Diffstat (limited to 'web/react')
-rw-r--r--web/react/components/channel_header.jsx17
-rw-r--r--web/react/components/channel_loader.jsx14
-rw-r--r--web/react/components/error_bar.jsx16
-rw-r--r--web/react/components/suggestion/at_mention_provider.jsx2
-rw-r--r--web/react/components/suggestion/command_provider.jsx2
-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.jsx16
-rw-r--r--web/react/utils/async_client.jsx4
-rw-r--r--web/react/utils/client.jsx28
-rw-r--r--web/react/utils/utils.jsx2
11 files changed, 74 insertions, 51 deletions
diff --git a/web/react/components/channel_header.jsx b/web/react/components/channel_header.jsx
index 727f84e8e..51be13dcf 100644
--- a/web/react/components/channel_header.jsx
+++ b/web/react/components/channel_header.jsx
@@ -194,6 +194,17 @@ export default class ChannelHeader extends React.Component {
);
}
+ let popoverListMembers;
+ if (!isDirect) {
+ popoverListMembers = (
+ <PopoverListMembers
+ members={this.state.users}
+ memberCount={this.state.userCount}
+ channelId={channel.id}
+ />
+ );
+ }
+
const dropdownContents = [];
if (isDirect) {
dropdownContents.push(
@@ -442,11 +453,7 @@ export default class ChannelHeader extends React.Component {
</div>
</th>
<th>
- <PopoverListMembers
- members={this.state.users}
- memberCount={this.state.userCount}
- channelId={channel.id}
- />
+ {popoverListMembers}
</th>
<th className='search-bar__container'><NavbarSearchBox/></th>
<th>
diff --git a/web/react/components/channel_loader.jsx b/web/react/components/channel_loader.jsx
index f3000ee05..e47f2aa50 100644
--- a/web/react/components/channel_loader.jsx
+++ b/web/react/components/channel_loader.jsx
@@ -6,6 +6,7 @@
AsyncClient with requests. */
import * as AsyncClient from '../utils/async_client.jsx';
+import * as Client from '../utils/client.jsx';
import SocketStore from '../stores/socket_store.jsx';
import ChannelStore from '../stores/channel_store.jsx';
import PostStore from '../stores/post_store.jsx';
@@ -45,6 +46,14 @@ const holders = defineMessages({
wrote: {
id: 'channel_loader.wrote',
defaultMessage: ' wrote: '
+ },
+ connectionError: {
+ id: 'channel_loader.connection_error',
+ defaultMessage: 'There appears to be a problem with your internet connection.'
+ },
+ unknownError: {
+ id: 'channel_loader.unknown_error',
+ defaultMessage: 'We received an unexpected status code from the server.'
}
});
@@ -67,6 +76,11 @@ class ChannelLoader extends React.Component {
wrote: formatMessage(holders.wrote)
});
+ Client.setTranslations({
+ connectionError: formatMessage(holders.connectionError),
+ unknownError: formatMessage(holders.unknownError)
+ });
+
this.state = {};
}
componentDidMount() {
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/suggestion/at_mention_provider.jsx b/web/react/components/suggestion/at_mention_provider.jsx
index 4dc72f69a..064b75ac5 100644
--- a/web/react/components/suggestion/at_mention_provider.jsx
+++ b/web/react/components/suggestion/at_mention_provider.jsx
@@ -89,7 +89,7 @@ export default class AtMentionProvider {
for (const id of Object.keys(users)) {
const user = users[id];
- if (user.username.startsWith(usernamePrefix)) {
+ if (user.username.startsWith(usernamePrefix) && user.delete_at <= 0) {
filtered.push(user);
}
diff --git a/web/react/components/suggestion/command_provider.jsx b/web/react/components/suggestion/command_provider.jsx
index 09c9b9982..21d6d0e0e 100644
--- a/web/react/components/suggestion/command_provider.jsx
+++ b/web/react/components/suggestion/command_provider.jsx
@@ -18,7 +18,7 @@ class CommandSuggestion extends React.Component {
onClick={onClick}
>
<div className='command__title'>
- <string>{item.suggestion}</string>
+ <string>{item.suggestion} {item.hint}</string>
</div>
<div className='command__desc'>
{item.description}
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..9b2b049b7 100644
--- a/web/react/stores/socket_store.jsx
+++ b/web/react/stores/socket_store.jsx
@@ -58,6 +58,10 @@ class SocketStoreClass extends EventEmitter {
if (this.failCount === 0) {
console.log('websocket connecting to ' + connUrl); //eslint-disable-line no-console
+ if (ErrorStore.getConnectionErrorCount() > 0) {
+ ErrorStore.setConnectionErrorCount(0);
+ ErrorStore.emitChange();
+ }
}
conn = new WebSocket(connUrl);
@@ -65,10 +69,8 @@ class SocketStoreClass extends EventEmitter {
if (this.failCount > 0) {
console.log('websocket re-established connection'); //eslint-disable-line no-console
- if (ErrorStore.getLastError()) {
- ErrorStore.storeLastError(null);
- ErrorStore.emitChange();
- }
+ ErrorStore.clearLastError();
+ ErrorStore.emitChange();
AsyncClient.getChannels();
AsyncClient.getPosts(ChannelStore.getCurrentId());
@@ -86,7 +88,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/async_client.jsx b/web/react/utils/async_client.jsx
index 13b57092d..ca9d81865 100644
--- a/web/react/utils/async_client.jsx
+++ b/web/react/utils/async_client.jsx
@@ -787,11 +787,13 @@ export function getSuggestedCommands(command, suggestionId, component) {
data.forEach((cmd) => {
if (('/' + cmd.trigger).indexOf(command) === 0) {
let s = '/' + cmd.trigger;
+ let hint = '';
if (cmd.auto_complete_hint && cmd.auto_complete_hint.length !== 0) {
- s += ' ' + cmd.auto_complete_hint;
+ hint = cmd.auto_complete_hint;
}
matches.push({
suggestion: s,
+ hint,
description: cmd.auto_complete_desc
});
}
diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx
index 81bdb7293..f647e2296 100644
--- a/web/react/utils/client.jsx
+++ b/web/react/utils/client.jsx
@@ -4,6 +4,15 @@ import BrowserStore from '../stores/browser_store.jsx';
import TeamStore from '../stores/team_store.jsx';
import ErrorStore from '../stores/error_store.jsx';
+let translations = {
+ connectionError: 'There appears to be a problem with your internet connection.',
+ unknownError: 'We received an unexpected status code from the server.'
+};
+
+export function setTranslations(messages) {
+ translations = messages;
+}
+
export function track(category, action, label, property, value) {
global.window.analytics.track(action, {category, label, property, value});
}
@@ -23,23 +32,14 @@ function handleError(methodName, xhr, status, err) {
var msg = '';
if (e) {
- msg = 'error in ' + methodName + ' msg=' + e.message + ' detail=' + e.detailed_error + ' rid=' + e.request_id;
+ msg = 'method=' + methodName + ' msg=' + e.message + ' detail=' + e.detailed_error + ' rid=' + e.request_id;
} else {
- msg = 'error in ' + methodName + ' status=' + status + ' statusCode=' + xhr.status + ' err=' + err;
+ msg = 'method=' + 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: translations.connectionError};
} else {
- e = {message: 'We received an unexpected status code from the server (' + xhr.status + ')'};
+ e = {message: translations.unknownError + ' (' + xhr.status + ')'};
}
}
@@ -279,7 +279,7 @@ export function logout() {
var currentTeamUrl = TeamStore.getCurrentTeamUrl();
BrowserStore.signalLogout();
BrowserStore.clear();
- ErrorStore.storeLastError(null);
+ ErrorStore.clearLastError();
window.location.href = currentTeamUrl + '/logout';
}
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 02590bd93..3e531c821 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -158,7 +158,7 @@ export function notifyMe(title, body, channel) {
Notification.requestPermission((permission) => {
if (permission === 'granted') {
try {
- var notification = new Notification(title, {body, tag: body, icon: '/static/images/icon50x50.png'});
+ var notification = new Notification(title, {body: body, tag: body, icon: '/static/images/icon50x50.png'});
notification.onclick = () => {
window.focus();
if (channel) {