From 5052039b36e3b3aa6ea309b601b66e9a079fe430 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Sun, 24 Feb 2019 04:42:04 +0000
Subject: [PATCH] Re-use SearchBox from filter rooms for filter room members
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/components/structures/LeftPanel.js | 2 ++
src/components/structures/SearchBox.js | 18 +++++++++---------
src/components/views/rooms/MemberList.js | 17 +++++++++--------
3 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/src/components/structures/LeftPanel.js b/src/components/structures/LeftPanel.js
index 000195d349..7088347ff4 100644
--- a/src/components/structures/LeftPanel.js
+++ b/src/components/structures/LeftPanel.js
@@ -26,6 +26,7 @@ import dis from '../../dispatcher';
import VectorConferenceHandler from '../../VectorConferenceHandler';
import TagPanelButtons from './TagPanelButtons';
import SettingsStore from '../../settings/SettingsStore';
+import {_t} from "../../languageHandler";
const LeftPanel = React.createClass({
@@ -212,6 +213,7 @@ const LeftPanel = React.createClass({
);
const searchBox = ();
diff --git a/src/components/structures/SearchBox.js b/src/components/structures/SearchBox.js
index 10628ccd13..056549d029 100644
--- a/src/components/structures/SearchBox.js
+++ b/src/components/structures/SearchBox.js
@@ -1,5 +1,6 @@
/*
Copyright 2015, 2016 OpenMarket Ltd
+Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -14,12 +15,9 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
-'use strict';
-
import React from 'react';
-import { _t } from '../../languageHandler';
+import PropTypes from 'prop-types';
import { KeyCode } from '../../Keyboard';
-import sdk from '../../index';
import dis from '../../dispatcher';
import { throttle } from 'lodash';
import AccessibleButton from '../../components/views/elements/AccessibleButton';
@@ -28,8 +26,10 @@ module.exports = React.createClass({
displayName: 'SearchBox',
propTypes: {
- onSearch: React.PropTypes.func,
- onCleared: React.PropTypes.func,
+ onSearch: PropTypes.func,
+ onCleared: PropTypes.func,
+ className: PropTypes.string,
+ placeholder: PropTypes.string.isRequired,
},
getInitialState: function() {
@@ -102,8 +102,8 @@ module.exports = React.createClass({
const clearButton = this.state.searchTerm.length > 0 ?
( {this._clearSearch("button")} }>
- ) : undefined;
+ onClick={ () => {this._clearSearch("button"); } }>
+ ) : undefined;
return (
@@ -116,7 +116,7 @@ module.exports = React.createClass({
onFocus={ this._onFocus }
onChange={ this.onChange }
onKeyDown={ this._onKeyDown }
- placeholder={ _t('Filter room names') }
+ placeholder={ this.props.placeholder }
/>
{ clearButton }
diff --git a/src/components/views/rooms/MemberList.js b/src/components/views/rooms/MemberList.js
index f01ef3e3ec..bd1d8cfe2b 100644
--- a/src/components/views/rooms/MemberList.js
+++ b/src/components/views/rooms/MemberList.js
@@ -339,12 +339,11 @@ module.exports = React.createClass({
return nameA.localeCompare(nameB);
},
- onSearchQueryChanged: function(ev) {
- const q = ev.target.value;
+ onSearchQueryChanged: function(searchQuery) {
this.setState({
- searchQuery: q,
- filteredJoinedMembers: this._filterMembers(this.state.members, 'join', q),
- filteredInvitedMembers: this._filterMembers(this.state.members, 'invite', q),
+ searchQuery,
+ filteredJoinedMembers: this._filterMembers(this.state.members, 'join', searchQuery),
+ filteredInvitedMembers: this._filterMembers(this.state.members, 'invite', searchQuery),
});
},
@@ -438,6 +437,7 @@ module.exports = React.createClass({
return
;
}
+ const SearchBox = sdk.getComponent('structures.SearchBox');
const TruncatedList = sdk.getComponent("elements.TruncatedList");
const GeminiScrollbarWrapper = sdk.getComponent("elements.GeminiScrollbarWrapper");
@@ -477,9 +477,10 @@ module.exports = React.createClass({
{ invitedSection }
-
+
+
);
},