summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-11-04 12:27:19 -0400
committerChristopher Speller <crspeller@gmail.com>2016-11-04 12:27:19 -0400
commit00787974d0a87b1a54f15cf75d2dab398546b87e (patch)
tree6f41b56b10183b6543309b790cd13b1fbf7559af /webapp
parent263f29068386cdd3b5393e00ce97f776532c723f (diff)
downloadchat-00787974d0a87b1a54f15cf75d2dab398546b87e.tar.gz
chat-00787974d0a87b1a54f15cf75d2dab398546b87e.tar.bz2
chat-00787974d0a87b1a54f15cf75d2dab398546b87e.zip
PLT-4481 Fix member count for team user lists and channel invite list (#4422)
* Fix member count for team user lists and channel invite list * Fix client unit test
Diffstat (limited to 'webapp')
-rw-r--r--webapp/components/admin_console/team_users.jsx6
-rw-r--r--webapp/components/channel_invite_modal.jsx6
-rw-r--r--webapp/components/member_list_team.jsx4
-rw-r--r--webapp/stores/user_store.jsx21
-rw-r--r--webapp/tests/client_team.test.jsx2
5 files changed, 24 insertions, 15 deletions
diff --git a/webapp/components/admin_console/team_users.jsx b/webapp/components/admin_console/team_users.jsx
index 3efb242ed..fce0f18ea 100644
--- a/webapp/components/admin_console/team_users.jsx
+++ b/webapp/components/admin_console/team_users.jsx
@@ -49,7 +49,7 @@ export default class UserList extends React.Component {
team: AdminStore.getTeam(this.props.params.team),
users: [],
teamMembers: TeamStore.getMembersInTeam(this.props.params.team),
- total: stats.member_count,
+ total: stats.total_member_count,
serverError: null,
showPasswordModal: false,
loading: true,
@@ -75,7 +75,7 @@ export default class UserList extends React.Component {
team: AdminStore.getTeam(nextProps.params.team),
users: [],
teamMembers: TeamStore.getMembersInTeam(nextProps.params.team),
- total: stats.member_count
+ total: stats.total_member_count
});
this.getTeamProfiles(nextProps.params.team);
@@ -102,7 +102,7 @@ export default class UserList extends React.Component {
onStatsChange() {
const stats = TeamStore.getStats(this.props.params.team);
- this.setState({total: stats.member_count});
+ this.setState({total: stats.total_member_count});
}
onUsersChange() {
diff --git a/webapp/components/channel_invite_modal.jsx b/webapp/components/channel_invite_modal.jsx
index 29607136c..89185435a 100644
--- a/webapp/components/channel_invite_modal.jsx
+++ b/webapp/components/channel_invite_modal.jsx
@@ -38,7 +38,7 @@ export default class ChannelInviteModal extends React.Component {
this.state = {
users: null,
- total: teamStats.member_count - channelStats.member_count,
+ total: teamStats.active_member_count - channelStats.member_count,
show: true,
search: false,
statusChange: false
@@ -72,8 +72,8 @@ export default class ChannelInviteModal extends React.Component {
const teamStats = TeamStore.getCurrentStats();
this.setState({
- users: UserStore.getProfileListNotInChannel(this.props.channel.id),
- total: teamStats.member_count - channelStats.member_count
+ users: UserStore.getProfileListNotInChannel(this.props.channel.id, true),
+ total: teamStats.active_member_count - channelStats.member_count
});
}
diff --git a/webapp/components/member_list_team.jsx b/webapp/components/member_list_team.jsx
index b32ab117d..8b23b650b 100644
--- a/webapp/components/member_list_team.jsx
+++ b/webapp/components/member_list_team.jsx
@@ -30,7 +30,7 @@ export default class MemberListTeam extends React.Component {
this.state = {
users: UserStore.getProfileListInTeam(),
teamMembers: Object.assign([], TeamStore.getMembersInTeam()),
- total: stats.member_count,
+ total: stats.total_member_count,
search: false,
loading: true
};
@@ -67,7 +67,7 @@ export default class MemberListTeam extends React.Component {
onStatsChange() {
const stats = TeamStore.getCurrentStats();
- this.setState({total: stats.member_count});
+ this.setState({total: stats.total_member_count});
}
nextPage(page) {
diff --git a/webapp/stores/user_store.jsx b/webapp/stores/user_store.jsx
index bb3415a7d..71b98d2e5 100644
--- a/webapp/stores/user_store.jsx
+++ b/webapp/stores/user_store.jsx
@@ -320,6 +320,10 @@ class UserStoreClass extends EventEmitter {
for (let i = 0; i < userIds.length; i++) {
const profile = this.getProfile(userIds[i]);
+ if (!profile) {
+ continue;
+ }
+
if (skipCurrent && profile.id === currentId) {
continue;
}
@@ -328,9 +332,7 @@ class UserStoreClass extends EventEmitter {
continue;
}
- if (profile) {
- profiles.push(profile);
- }
+ profiles.push(profile);
}
return profiles;
@@ -473,15 +475,22 @@ class UserStoreClass extends EventEmitter {
userIds.splice(index, 1);
}
- getProfileListNotInChannel(channelId = ChannelStore.getCurrentId()) {
+ getProfileListNotInChannel(channelId = ChannelStore.getCurrentId(), skipInactive = false) {
const userIds = this.profiles_not_in_channel[channelId] || [];
const profiles = [];
for (let i = 0; i < userIds.length; i++) {
const profile = this.getProfile(userIds[i]);
- if (profile) {
- profiles.push(profile);
+
+ if (!profile) {
+ continue;
}
+
+ if (skipInactive && profile.delete_at > 0) {
+ continue;
+ }
+
+ profiles.push(profile);
}
return profiles;
diff --git a/webapp/tests/client_team.test.jsx b/webapp/tests/client_team.test.jsx
index 642307986..ab2e625bf 100644
--- a/webapp/tests/client_team.test.jsx
+++ b/webapp/tests/client_team.test.jsx
@@ -169,7 +169,7 @@ describe('Client.Team', function() {
TestHelper.basicClient().getTeamStats(
TestHelper.basicTeam().id,
function(data) {
- assert.equal(data.member_count > 0, true);
+ assert.equal(data.total_member_count > 0, true);
done();
},
function(err) {