Discard outdated results in modal searches (#5082)
Этот коммит содержится в:
коммит произвёл
Corey Hulen
родитель
4257114a37
Коммит
6b2c4a346b
@@ -158,13 +158,17 @@ export default class UserList extends React.Component {
|
||||
|
||||
clearTimeout(this.searchTimeoutId);
|
||||
|
||||
this.searchTimeoutId = setTimeout(
|
||||
const searchTimeoutId = setTimeout(
|
||||
() => {
|
||||
searchUsers(
|
||||
term,
|
||||
this.props.params.team,
|
||||
options,
|
||||
(users) => {
|
||||
if (searchTimeoutId !== this.searchTimeoutId) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({loading: true, search: true, users});
|
||||
loadTeamMembersForProfilesList(users, this.props.params.team, this.loadComplete);
|
||||
}
|
||||
@@ -172,6 +176,8 @@ export default class UserList extends React.Component {
|
||||
},
|
||||
Constants.SEARCH_TIMEOUT_MILLISECONDS
|
||||
);
|
||||
|
||||
this.searchTimeoutId = searchTimeoutId;
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -117,19 +117,25 @@ export default class ChannelInviteModal extends React.Component {
|
||||
|
||||
clearTimeout(this.searchTimeoutId);
|
||||
|
||||
this.searchTimeoutId = setTimeout(
|
||||
const searchTimeoutId = setTimeout(
|
||||
() => {
|
||||
searchUsers(
|
||||
term,
|
||||
TeamStore.getCurrentId(),
|
||||
{not_in_channel_id: this.props.channel.id},
|
||||
(users) => {
|
||||
if (searchTimeoutId !== this.searchTimeoutId) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({search: true, users});
|
||||
}
|
||||
);
|
||||
},
|
||||
Constants.SEARCH_TIMEOUT_MILLISECONDS
|
||||
);
|
||||
|
||||
this.searchTimeoutId = searchTimeoutId;
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -104,13 +104,17 @@ export default class MemberListChannel extends React.Component {
|
||||
|
||||
clearTimeout(this.searchTimeoutId);
|
||||
|
||||
this.searchTimeoutId = setTimeout(
|
||||
const searchTimeoutId = setTimeout(
|
||||
() => {
|
||||
searchUsers(
|
||||
term,
|
||||
TeamStore.getCurrentId(),
|
||||
{},
|
||||
(users) => {
|
||||
if (searchTimeoutId !== this.searchTimeoutId) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({
|
||||
loading: true,
|
||||
search: true,
|
||||
@@ -125,6 +129,8 @@ export default class MemberListChannel extends React.Component {
|
||||
},
|
||||
Constants.SEARCH_TIMEOUT_MILLISECONDS
|
||||
);
|
||||
|
||||
this.searchTimeoutId = searchTimeoutId;
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -23,6 +23,7 @@ export default class MemberListTeam extends React.Component {
|
||||
super(props);
|
||||
|
||||
this.onChange = this.onChange.bind(this);
|
||||
this.onTeamChange = this.onTeamChange.bind(this);
|
||||
this.onStatsChange = this.onStatsChange.bind(this);
|
||||
this.search = this.search.bind(this);
|
||||
this.loadComplete = this.loadComplete.bind(this);
|
||||
@@ -44,7 +45,7 @@ export default class MemberListTeam extends React.Component {
|
||||
componentDidMount() {
|
||||
UserStore.addInTeamChangeListener(this.onChange);
|
||||
UserStore.addStatusesChangeListener(this.onChange);
|
||||
TeamStore.addChangeListener(this.onChange.bind(null, true));
|
||||
TeamStore.addChangeListener(this.onTeamChange);
|
||||
TeamStore.addStatsChangeListener(this.onStatsChange);
|
||||
|
||||
loadProfilesAndTeamMembers(0, Constants.PROFILE_CHUNK_SIZE, TeamStore.getCurrentId(), this.loadComplete);
|
||||
@@ -54,7 +55,7 @@ export default class MemberListTeam extends React.Component {
|
||||
componentWillUnmount() {
|
||||
UserStore.removeInTeamChangeListener(this.onChange);
|
||||
UserStore.removeStatusesChangeListener(this.onChange);
|
||||
TeamStore.removeChangeListener(this.onChange);
|
||||
TeamStore.removeChangeListener(this.onTeamChange);
|
||||
TeamStore.removeStatsChangeListener(this.onStatsChange);
|
||||
}
|
||||
|
||||
@@ -62,6 +63,10 @@ export default class MemberListTeam extends React.Component {
|
||||
this.setState({loading: false});
|
||||
}
|
||||
|
||||
onTeamChange() {
|
||||
this.onChange(true);
|
||||
}
|
||||
|
||||
onChange(force) {
|
||||
if (this.state.search && !force) {
|
||||
return;
|
||||
@@ -90,13 +95,16 @@ export default class MemberListTeam extends React.Component {
|
||||
|
||||
clearTimeout(this.searchTimeoutId);
|
||||
|
||||
this.searchTimeoutId = setTimeout(
|
||||
const searchTimeoutId = setTimeout(
|
||||
() => {
|
||||
searchUsers(
|
||||
term,
|
||||
TeamStore.getCurrentId(),
|
||||
{},
|
||||
(users) => {
|
||||
if (searchTimeoutId !== this.searchTimeoutId) {
|
||||
return;
|
||||
}
|
||||
this.setState({loading: true, search: true, users, term, teamMembers: Object.assign([], TeamStore.getMembersInTeam())});
|
||||
loadTeamMembersForProfilesList(users, TeamStore.getCurrentId(), this.loadComplete);
|
||||
}
|
||||
@@ -104,6 +112,8 @@ export default class MemberListTeam extends React.Component {
|
||||
},
|
||||
Constants.SEARCH_TIMEOUT_MILLISECONDS
|
||||
);
|
||||
|
||||
this.searchTimeoutId = searchTimeoutId;
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -107,17 +107,22 @@ export default class MoreChannels extends React.Component {
|
||||
|
||||
clearTimeout(this.searchTimeoutId);
|
||||
|
||||
this.searchTimeoutId = setTimeout(
|
||||
const searchTimeoutId = setTimeout(
|
||||
() => {
|
||||
searchMoreChannels(
|
||||
term,
|
||||
(channels) => {
|
||||
if (searchTimeoutId !== this.searchTimeoutId) {
|
||||
return;
|
||||
}
|
||||
this.setState({search: true, channels});
|
||||
}
|
||||
);
|
||||
},
|
||||
SEARCH_TIMEOUT_MILLISECONDS
|
||||
);
|
||||
|
||||
this.searchTimeoutId = searchTimeoutId;
|
||||
}
|
||||
|
||||
render() {
|
||||
@@ -196,4 +201,4 @@ export default class MoreChannels extends React.Component {
|
||||
MoreChannels.propTypes = {
|
||||
onModalDismissed: React.PropTypes.func,
|
||||
handleNewChannel: React.PropTypes.func
|
||||
};
|
||||
};
|
||||
|
||||
@@ -379,5 +379,7 @@ TeamStore.dispatchToken = AppDispatcher.register((payload) => {
|
||||
}
|
||||
});
|
||||
|
||||
TeamStore.setMaxListeners(15);
|
||||
|
||||
window.TeamStore = TeamStore;
|
||||
export default TeamStore;
|
||||
|
||||
Ссылка в новой задаче
Block a user