Search DM's using profiles and not search store (#402)

* Fix localization strings

* Make DM search to use the profiles instead of the search store
This commit is contained in:
enahum 2017-03-26 23:06:47 -03:00 committed by GitHub
parent 58f1b3a552
commit 6eb9920758
5 changed files with 18 additions and 26 deletions

View file

@ -23,8 +23,7 @@ const state = {
profilesInTeam: {},
profilesInChannel: {},
profilesNotInChannel: {},
statuses: {},
search: {}
statuses: {}
},
teams: {
currentTeamId: '',

View file

@ -85,16 +85,11 @@ class ChannelMembers extends PureComponent {
Alert.alert(
formatMessage({
id: 'mobile.routes.channel_members.action',
defaultMessage: '{term} Members'
}, {
term: 'Remove'
defaultMessage: 'Remove Members'
}),
formatMessage({
id: 'mobile.routes.channel_members.action_message',
defaultMessage: 'You must select at least one member to {term} {prep} the channel.'
}, {
term: 'remove',
prep: 'from'
defaultMessage: 'You must select at least one member to remove from the channel.'
})
);
return;
@ -103,16 +98,11 @@ class ChannelMembers extends PureComponent {
Alert.alert(
formatMessage({
id: 'mobile.routes.channel_members.action',
defaultMessage: '{term} Members'
}, {
term: 'Remove'
defaultMessage: 'Remove Members'
}),
formatMessage({
id: 'mobile.routes.channel_members.action_message_confirm',
defaultMessage: 'Are you sure you want to {term} the selected members {prep} the channel?'
}, {
term: 'remove',
prep: 'from'
defaultMessage: 'Are you sure you want to remove the selected members from the channel?'
}),
[{
text: formatMessage({id: 'mobile.channel_list.alertNo', defaultMessage: 'No'})

View file

@ -10,7 +10,6 @@ import {makeDirectChannel} from 'app/actions/views/more_dms';
import {getTheme} from 'app/selectors/preferences';
import {getProfiles, searchProfiles} from 'mattermost-redux/actions/users';
import {getMyPreferences} from 'mattermost-redux/selectors/entities/preferences';
import {searchProfiles as searchSelector} from 'mattermost-redux/selectors/entities/users';
import MoreDirectMessages from './more_dms';
@ -33,7 +32,6 @@ function mapStateToProps(state, ownProps) {
...ownProps,
preferences: getMyPreferences(state),
profiles: getUsers(),
search: searchSelector(state),
theme: getTheme(state),
requestStatus,
searchRequest

View file

@ -26,7 +26,6 @@ class MoreDirectMessages extends PureComponent {
preferences: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired,
profiles: PropTypes.array,
search: PropTypes.array,
requestStatus: PropTypes.object.isRequired,
searchRequest: PropTypes.object.isRequired,
subscribeToHeaderEvent: React.PropTypes.func.isRequired,
@ -83,7 +82,12 @@ class MoreDirectMessages extends PureComponent {
this.setState({profiles});
} else if (this.state.searching &&
nextProps.searchRequest.status === RequestStatus.SUCCESS) {
this.setState({profiles: nextProps.search});
const results = nextProps.profiles.filter((p) => {
const {term} = this.state;
return p.username.toLowerCase().includes(term) || p.email.toLowerCase().includes(term) ||
p.first_name.toLowerCase().includes(term) || p.last_name.toLowerCase().includes(term);
});
this.setState({profiles: results});
}
}
@ -121,7 +125,7 @@ class MoreDirectMessages extends PureComponent {
const term = event.nativeEvent.text;
if (term) {
this.setState({searching: true});
this.setState({searching: true, term: term.toLowerCase()});
clearTimeout(this.searchTimeoutId);
this.searchTimeoutId = setTimeout(() => {
@ -133,10 +137,11 @@ class MoreDirectMessages extends PureComponent {
};
cancelSearch = () => {
this.props.actions.getProfiles(0);
this.setState({
searching: false,
page: 0
term: null,
page: 0,
profiles: this.props.profiles
});
};

View file

@ -1543,9 +1543,9 @@
"mobile.routes.channelInfo.createdBy": "Created by {creator} on ",
"mobile.routes.channelInfo.delete_channel": "Delete Channel",
"mobile.routes.channelInfo.favorite": "Favorite",
"mobile.routes.channel_members.action": "{term} Members",
"mobile.routes.channel_members.action_message": "You must select at least one member to {term} {prep} the channel.",
"mobile.routes.channel_members.action_message_confirm": "Are you sure you want to {term} the selected members {prep} the channel?",
"mobile.routes.channel_members.action": "Remove Members",
"mobile.routes.channel_members.action_message": "You must select at least one member to remove from the channel.",
"mobile.routes.channel_members.action_message_confirm": "Are you sure you want to remove the selected members from the channel?",
"mobile.routes.thread": "{channelName} Thread",
"mobile.routes.thread_dm": "Direct Message Thread",
"mobile.routes.user_profile": "Profile",