From b1236f2f212252f3aa7d1cd723cb034343fa8959 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Tue, 26 Feb 2019 09:46:27 -0300 Subject: [PATCH] [FIX] Room members filter (#655) --- app/views/RoomMembersView/index.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/app/views/RoomMembersView/index.js b/app/views/RoomMembersView/index.js index 92e78d082..932e46c62 100644 --- a/app/views/RoomMembersView/index.js +++ b/app/views/RoomMembersView/index.js @@ -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);