From af3c43ca765294578fd53af5cfcecabe33220140 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Fri, 11 Dec 2015 02:58:59 +0000 Subject: [PATCH] show result counts --- src/components/structures/RoomView.js | 23 ++++++++++++++++++----- src/components/views/rooms/RoomHeader.js | 8 ++++++++ 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 7f089f6f9b..1dc2440913 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -479,8 +479,10 @@ module.exports = React.createClass({ self.setState({ highlights: highlights, + searchTerm: term, searchResults: data, searchScope: scope, + searchCount: data.search_categories.room_events.count, }); }, function(error) { var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); @@ -505,10 +507,14 @@ module.exports = React.createClass({ var EventTile = sdk.getComponent('rooms.EventTile'); var self = this; - if (this.state.searchResults && - this.state.searchResults.search_categories.room_events.results && - this.state.searchResults.search_categories.room_events.groups) + if (this.state.searchResults) { + if (!this.state.searchResults.search_categories.room_events.results || + !this.state.searchResults.search_categories.room_events.groups) + { + return ret; + } + // XXX: this dance is foul, due to the results API not directly returning sorted results var results = this.state.searchResults.search_categories.room_events.results; var roomIdGroups = this.state.searchResults.search_categories.room_events.groups.room_id; @@ -985,15 +991,22 @@ module.exports = React.createClass({ ; } - var messageComposer; + var messageComposer, searchInfo; if (!this.state.searchResults) { messageComposer = } + else { + searchInfo = { + searchTerm : this.state.searchTerm, + searchScope : this.state.searchScope, + searchCount : this.state.searchCount, + } + } return (
-
diff --git a/src/components/views/rooms/RoomHeader.js b/src/components/views/rooms/RoomHeader.js index 0f5084e7ee..f2ab5ea669 100644 --- a/src/components/views/rooms/RoomHeader.js +++ b/src/components/views/rooms/RoomHeader.js @@ -187,6 +187,7 @@ module.exports = React.createClass({ } var name = null; + var searchStatus = null; var topic_el = null; var cancel_button = null; var save_button = null; @@ -203,9 +204,16 @@ module.exports = React.createClass({ save_button =
Save Changes
} else { // + + var searchStatus; + if (this.props.searchInfo && this.props.searchInfo.searchTerm) { + searchStatus =
 ({ this.props.searchInfo.searchCount } results)
; + } + name =
{ this.props.room.name }
+ { searchStatus }