From a9f414dafed7a00ffab9eec4494367c0ce1c1cc4 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 13 Mar 2020 23:23:23 +0000 Subject: [PATCH] Remove unused SearchableEntityList.js Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- res/css/_components.scss | 1 - .../views/rooms/_SearchableEntityList.scss | 77 -------- src/components/structures/RoomView.js | 15 -- .../views/rooms/SearchableEntityList.js | 186 ------------------ 4 files changed, 279 deletions(-) delete mode 100644 res/css/views/rooms/_SearchableEntityList.scss delete mode 100644 src/components/views/rooms/SearchableEntityList.js diff --git a/res/css/_components.scss b/res/css/_components.scss index bc636eb3c6..68322b9660 100644 --- a/res/css/_components.scss +++ b/res/css/_components.scss @@ -177,7 +177,6 @@ @import "./views/rooms/_RoomTile.scss"; @import "./views/rooms/_RoomUpgradeWarningBar.scss"; @import "./views/rooms/_SearchBar.scss"; -@import "./views/rooms/_SearchableEntityList.scss"; @import "./views/rooms/_SendMessageComposer.scss"; @import "./views/rooms/_Stickers.scss"; @import "./views/rooms/_TopUnreadMessagesBar.scss"; diff --git a/res/css/views/rooms/_SearchableEntityList.scss b/res/css/views/rooms/_SearchableEntityList.scss deleted file mode 100644 index 37a663123d..0000000000 --- a/res/css/views/rooms/_SearchableEntityList.scss +++ /dev/null @@ -1,77 +0,0 @@ -/* -Copyright 2016 OpenMarket Ltd - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -.mx_SearchableEntityList { - display: flex; - - flex-direction: column; -} - -.mx_SearchableEntityList_query { - font-family: $font-family; - border-radius: 3px; - border: 1px solid $input-border-color; - padding: 9px; - color: $primary-fg-color; - background-color: $primary-bg-color; - margin-left: 3px; - font-size: 15px; - margin-bottom: 8px; - width: 189px; -} - -.mx_SearchableEntityList_query::-moz-placeholder { - color: $primary-fg-color; - opacity: 0.5; - font-size: 12px; -} - -.mx_SearchableEntityList_query::-webkit-input-placeholder { - color: $primary-fg-color; - opacity: 0.5; - font-size: 12px; -} - -.mx_SearchableEntityList_listWrapper { - flex: 1; - - overflow-y: auto; -} - -.mx_SearchableEntityList_list { - display: table; - table-layout: fixed; - width: 100%; -} - -.mx_SearchableEntityList_list .mx_EntityTile_chevron { - display: none; -} - -.mx_SearchableEntityList_hrWrapper { - width: 100%; - flex: 0 0 auto; -} - -.mx_SearchableEntityList hr { - height: 1px; - border: 0px; - color: $primary-fg-color; - background-color: $primary-fg-color; - margin-right: 15px; - margin-top: 11px; - margin-bottom: 11px; -} diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 36e30343e4..17a496b037 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -405,21 +405,6 @@ export default createReactClass({ this.onResize(); document.addEventListener("keydown", this.onKeyDown); - - // XXX: EVIL HACK to autofocus inviting on empty rooms. - // We use the setTimeout to avoid racing with focus_composer. - if (this.state.room && - this.state.room.getJoinedMemberCount() == 1 && - this.state.room.getLiveTimeline() && - this.state.room.getLiveTimeline().getEvents() && - this.state.room.getLiveTimeline().getEvents().length <= 6) { - const inviteBox = document.getElementById("mx_SearchableEntityList_query"); - setTimeout(function() { - if (inviteBox) { - inviteBox.focus(); - } - }, 50); - } }, shouldComponentUpdate: function(nextProps, nextState) { diff --git a/src/components/views/rooms/SearchableEntityList.js b/src/components/views/rooms/SearchableEntityList.js deleted file mode 100644 index 807ddbf729..0000000000 --- a/src/components/views/rooms/SearchableEntityList.js +++ /dev/null @@ -1,186 +0,0 @@ -/* -Copyright 2015, 2016 OpenMarket Ltd -Copyright 2019 The Matrix.org Foundation C.I.C. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -import React from 'react'; -import PropTypes from 'prop-types'; -import createReactClass from 'create-react-class'; -import * as sdk from "../../../index"; -import { _t } from '../../../languageHandler'; - -// A list capable of displaying entities which conform to the SearchableEntity -// interface which is an object containing getJsx(): Jsx and matches(query: string): boolean -const SearchableEntityList = createReactClass({ - displayName: 'SearchableEntityList', - - propTypes: { - emptyQueryShowsAll: PropTypes.bool, - showInputBox: PropTypes.bool, - onQueryChanged: PropTypes.func, // fn(inputText) - onSubmit: PropTypes.func, // fn(inputText) - entities: PropTypes.array, - truncateAt: PropTypes.number, - }, - - getDefaultProps: function() { - return { - showInputBox: true, - entities: [], - emptyQueryShowsAll: false, - onSubmit: function() {}, - onQueryChanged: function(input) {}, - }; - }, - - getInitialState: function() { - return { - query: "", - focused: false, - truncateAt: this.props.truncateAt, - results: this.getSearchResults("", this.props.entities), - }; - }, - - componentWillReceiveProps: function(newProps) { - // recalculate the search results in case we got new entities - this.setState({ - results: this.getSearchResults(this.state.query, newProps.entities), - }); - }, - - componentWillUnmount: function() { - // pretend the query box was blanked out else filters could still be - // applied to other components which rely on onQueryChanged. - this.props.onQueryChanged(""); - }, - - /** - * Public-facing method to set the input query text to the given input. - * @param {string} input - */ - setQuery: function(input) { - this.setState({ - query: input, - results: this.getSearchResults(input, this.props.entities), - }); - }, - - onQueryChanged: function(ev) { - const q = ev.target.value; - this.setState({ - query: q, - // reset truncation if they back out the entire text - truncateAt: (q.length === 0 ? this.props.truncateAt : this.state.truncateAt), - results: this.getSearchResults(q, this.props.entities), - }, () => { - // invoke the callback AFTER we've flushed the new state. We need to - // do this because onQueryChanged can result in new props being passed - // to this component, which will then try to recalculate the search - // list. If we do this without flushing, we'll recalc with the last - // search term and not the current one! - this.props.onQueryChanged(q); - }); - }, - - onQuerySubmit: function(ev) { - ev.preventDefault(); - this.props.onSubmit(this.state.query); - }, - - getSearchResults: function(query, entities) { - if (!query || query.length === 0) { - return this.props.emptyQueryShowsAll ? entities : []; - } - return entities.filter(function(e) { - return e.matches(query); - }); - }, - - _showAll: function() { - this.setState({ - truncateAt: -1, - }); - }, - - _createOverflowEntity: function(overflowCount, totalCount) { - const EntityTile = sdk.getComponent("rooms.EntityTile"); - const BaseAvatar = sdk.getComponent("avatars.BaseAvatar"); - const text = _t("and %(count)s others...", { count: overflowCount }); - return ( - - } name={text} presenceState="online" suppressOnHover={true} - onClick={this._showAll} /> - ); - }, - - render: function() { - let inputBox; - - if (this.props.showInputBox) { - inputBox = ( -
- { this.setState({ focused: true }); }} - onBlur= {() => { this.setState({ focused: false }); }} - placeholder={_t("Search")} /> -
- ); - } - - let list; - if (this.state.results.length > 1 || this.state.focused) { - if (this.props.truncateAt) { // caller wants list truncated - const TruncatedList = sdk.getComponent("elements.TruncatedList"); - list = ( - - { this.state.results.map((entity) => { - return entity.getJsx(); - }) } - - ); - } else { - list = ( -
- { this.state.results.map((entity) => { - return entity.getJsx(); - }) } -
- ); - } - const GeminiScrollbarWrapper = sdk.getComponent("elements.GeminiScrollbarWrapper"); - list = ( - - { list } - - ); - } - - return ( -
- { inputBox } - { list } - { list ?

: '' } -
- ); - }, -}); - -export default SearchableEntityList;