summaryrefslogtreecommitdiffstats
path: root/webapp/components
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-02-13 09:27:28 -0500
committerCorey Hulen <corey@hulen.com>2017-02-13 09:27:28 -0500
commitff741740eebceb43b1d69b13d97ae7eed2aa32d1 (patch)
tree0f795cea935a72997bf3618ceaf3b0513d5e8096 /webapp/components
parentfac85b676eafb20b5f70db1805006d64889606ff (diff)
downloadchat-ff741740eebceb43b1d69b13d97ae7eed2aa32d1.tar.gz
chat-ff741740eebceb43b1d69b13d97ae7eed2aa32d1.tar.bz2
chat-ff741740eebceb43b1d69b13d97ae7eed2aa32d1.zip
Increase performance when receiving messages (#5375)
Diffstat (limited to 'webapp/components')
-rw-r--r--webapp/components/needs_team.jsx9
-rw-r--r--webapp/components/post_view/post_view_cache.jsx2
-rw-r--r--webapp/components/team_sidebar/components/team_button.jsx10
3 files changed, 19 insertions, 2 deletions
diff --git a/webapp/components/needs_team.jsx b/webapp/components/needs_team.jsx
index 0b91814c3..fb6029c2b 100644
--- a/webapp/components/needs_team.jsx
+++ b/webapp/components/needs_team.jsx
@@ -42,6 +42,8 @@ import SelectTeamModal from 'components/admin_console/select_team_modal.jsx';
import iNoBounce from 'inobounce';
import * as UserAgent from 'utils/user_agent.jsx';
+const UNREAD_CHECK_TIME_MILLISECONDS = 10000;
+
export default class NeedsTeam extends React.Component {
constructor(params) {
super(params);
@@ -49,6 +51,8 @@ export default class NeedsTeam extends React.Component {
this.onTeamChanged = this.onTeamChanged.bind(this);
this.onPreferencesChanged = this.onPreferencesChanged.bind(this);
+ this.blurTime = new Date().getTime();
+
const team = TeamStore.getCurrent();
this.state = {
@@ -97,11 +101,16 @@ export default class NeedsTeam extends React.Component {
AsyncClient.viewChannel();
ChannelStore.resetCounts(ChannelStore.getCurrentId());
ChannelStore.emitChange();
+
window.isActive = true;
+ if (new Date().getTime() - this.blurTime > UNREAD_CHECK_TIME_MILLISECONDS) {
+ AsyncClient.getMyChannelMembers();
+ }
});
$(window).on('blur', () => {
window.isActive = false;
+ this.blurTime = new Date().getTime();
if (UserStore.getCurrentUser()) {
AsyncClient.viewChannel('');
}
diff --git a/webapp/components/post_view/post_view_cache.jsx b/webapp/components/post_view/post_view_cache.jsx
index 9c3f1db1b..b0b35a5c0 100644
--- a/webapp/components/post_view/post_view_cache.jsx
+++ b/webapp/components/post_view/post_view_cache.jsx
@@ -33,7 +33,7 @@ export default class PostViewCache extends React.Component {
componentWillUnmount() {
if (UserStore.getCurrentUser()) {
- AsyncClient.viewChannel('');
+ AsyncClient.viewChannel('', this.state.currentChannelId || '');
}
ChannelStore.removeChangeListener(this.onChannelChange);
}
diff --git a/webapp/components/team_sidebar/components/team_button.jsx b/webapp/components/team_sidebar/components/team_button.jsx
index 2df21b20b..6fbf8aef9 100644
--- a/webapp/components/team_sidebar/components/team_button.jsx
+++ b/webapp/components/team_sidebar/components/team_button.jsx
@@ -3,6 +3,8 @@
import Constants from 'utils/constants.jsx';
+import {switchTeams} from 'actions/team_actions.jsx';
+
import React from 'react';
import {Link} from 'react-router/es6';
import {Tooltip, OverlayTrigger} from 'react-bootstrap';
@@ -11,9 +13,15 @@ export default class TeamButton extends React.Component {
constructor(props) {
super(props);
+ this.handleSwitch = this.handleSwitch.bind(this);
this.handleDisabled = this.handleDisabled.bind(this);
}
+ handleSwitch(e) {
+ e.preventDefault();
+ switchTeams(this.props.url);
+ }
+
handleDisabled(e) {
e.preventDefault();
}
@@ -22,7 +30,7 @@ export default class TeamButton extends React.Component {
let teamClass = this.props.active ? 'active' : '';
const btnClass = this.props.btnClass;
const disabled = this.props.disabled ? 'team-disabled' : '';
- const handleClick = (this.props.active || this.props.disabled) ? this.handleDisabled : null;
+ const handleClick = (this.props.active || this.props.disabled) ? this.handleDisabled : this.handleSwitch;
let badge;
if (!teamClass) {