Skip to content

Commit

Permalink
Remove race between clearing lists and search requests (#5686)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilander authored and grundleborg committed Mar 9, 2017
1 parent bfc8daf commit cbead2d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
5 changes: 3 additions & 2 deletions webapp/components/admin_console/team_users.jsx
Expand Up @@ -148,16 +148,17 @@ export default class UserList extends React.Component {
}

search(term) {
clearTimeout(this.searchTimeoutId);

if (term === '') {
this.setState({search: false, users: UserStore.getProfileListInTeam(this.props.params.team)});
this.searchTimeoutId = '';
return;
}

const options = {};
options[UserSearchOptions.ALLOW_INACTIVE] = true;

clearTimeout(this.searchTimeoutId);

const searchTimeoutId = setTimeout(
() => {
searchUsers(
Expand Down
5 changes: 3 additions & 2 deletions webapp/components/channel_invite_modal.jsx
Expand Up @@ -107,16 +107,17 @@ export default class ChannelInviteModal extends React.Component {
}

search(term) {
clearTimeout(this.searchTimeoutId);

this.term = term;

if (term === '') {
this.onChange(true);
this.setState({search: false});
this.searchTimeoutId = '';
return;
}

clearTimeout(this.searchTimeoutId);

const searchTimeoutId = setTimeout(
() => {
searchUsers(
Expand Down
5 changes: 3 additions & 2 deletions webapp/components/member_list_channel.jsx
Expand Up @@ -91,6 +91,8 @@ export default class MemberListChannel extends React.Component {
}

search(term) {
clearTimeout(this.searchTimeoutId);

if (term === '') {
this.setState({
search: false,
Expand All @@ -99,11 +101,10 @@ export default class MemberListChannel extends React.Component {
teamMembers: Object.assign([], TeamStore.getMembersInTeam()),
channelMembers: Object.assign([], ChannelStore.getMembersInChannel())
});
this.searchTimeoutId = '';
return;
}

clearTimeout(this.searchTimeoutId);

const searchTimeoutId = setTimeout(
() => {
searchUsers(
Expand Down
5 changes: 3 additions & 2 deletions webapp/components/member_list_team.jsx
Expand Up @@ -88,13 +88,14 @@ export default class MemberListTeam extends React.Component {
}

search(term) {
clearTimeout(this.searchTimeoutId);

if (term === '') {
this.setState({search: false, term, users: UserStore.getProfileListInTeam(), teamMembers: Object.assign([], TeamStore.getMembersInTeam())});
this.searchTimeoutId = '';
return;
}

clearTimeout(this.searchTimeoutId);

const searchTimeoutId = setTimeout(
() => {
searchUsers(
Expand Down
5 changes: 3 additions & 2 deletions webapp/components/more_channels.jsx
Expand Up @@ -99,14 +99,15 @@ export default class MoreChannels extends React.Component {
}

search(term) {
clearTimeout(this.searchTimeoutId);

if (term === '') {
this.onChange(true);
this.setState({search: false});
this.searchTimeoutId = '';
return;
}

clearTimeout(this.searchTimeoutId);

const searchTimeoutId = setTimeout(
() => {
searchMoreChannels(
Expand Down

0 comments on commit cbead2d

Please sign in to comment.