[FIX] Room members filter (#655)

This commit is contained in:
Diego Mello 2019-02-26 09:46:27 -03:00 committed by GitHub
parent e9f57e0337
commit b1236f2f21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 10 deletions

View File

@ -20,6 +20,7 @@ import log from '../../utils/log';
import { isAndroid } from '../../utils/deviceInfo';
import I18n from '../../i18n';
import SearchBox from '../../containers/SearchBox';
import protectedFunction from '../../lib/methods/helpers/protectedFunction';
@connect(state => ({
baseUrl: state.settings.Site_Url || state.server ? state.server.server : '',
@ -118,6 +119,16 @@ export default class RoomMembersView extends LoggedView {
this.rooms.removeAllListeners();
}
onSearchChangeText = protectedFunction((text) => {
const { members } = this.state;
let membersFiltered = [];
if (members && members.length > 0 && text) {
membersFiltered = members.filter(m => m.username.toLowerCase().match(text.toLowerCase()));
}
this.setState({ filtering: !!text, membersFiltered });
})
navigationButtonPressed = ({ buttonId }) => {
const { allUsers } = this.state;
const { componentId } = this.props;
@ -141,16 +152,6 @@ export default class RoomMembersView extends LoggedView {
}
}
onSearchChangeText = (text) => {
const { members } = this.state;
let membersFiltered = [];
if (text) {
membersFiltered = members.filter(m => m.username.toLowerCase().match(text.toLowerCase()));
}
this.setState({ filtering: !!text, membersFiltered });
}
onPressUser = async(item) => {
try {
const subscriptions = database.objects('subscriptions').filtered('name = $0', item.username);