Skip to content

Commit 83b3702

Browse files
committed
Merge branch 'develop' into kegan/controller-merging4
2 parents 450b2d4 + cd040ae commit 83b3702

15 files changed

Lines changed: 106 additions & 62 deletions

File tree

‎src/controllers/organisms/RoomView.js‎

Lines changed: 69 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ module.exports = {
288288

289289
fillSpace: function() {
290290
if (!this.refs.messagePanel) return;
291+
if (this.state.searchResults) return; // TODO: paginate search results
291292
var messageWrapperScroll = this._getScrollNode();
292293
if (messageWrapperScroll.scrollTop < messageWrapperScroll.clientHeight && this.state.room.oldState.paginationToken) {
293294
this.setState({paginating: true});
@@ -426,7 +427,7 @@ module.exports = {
426427

427428
onSearch: function(term, scope) {
428429
var filter;
429-
if (scope === "Room") { // FIXME: should be enum
430+
if (scope === "Room") {
430431
filter = {
431432
// XXX: it's unintuitive that the filter for searching doesn't have the same shape as the v2 filter API :(
432433
rooms: [
@@ -443,6 +444,14 @@ module.exports = {
443444
search_term: term,
444445
filter: filter,
445446
order_by: "recent",
447+
include_state: true,
448+
groupings: {
449+
group_by: [
450+
{
451+
key: "room_id"
452+
}
453+
]
454+
},
446455
event_context: {
447456
before_limit: 1,
448457
after_limit: 1,
@@ -451,9 +460,28 @@ module.exports = {
451460
}
452461
}
453462
}).then(function(data) {
463+
// for debugging:
464+
// data.search_categories.room_events.highlights = ["hello", "everybody"];
465+
466+
var highlights;
467+
if (data.search_categories.room_events.highlights &&
468+
data.search_categories.room_events.highlights.length > 0)
469+
{
470+
// postgres on synapse returns us precise details of the
471+
// strings which actually got matched for highlighting.
472+
// for overlapping highlights, favour longer (more specific) terms first
473+
highlights = data.search_categories.room_events.highlights
474+
.sort(function(a, b) { b.length - a.length });
475+
}
476+
else {
477+
// sqlite doesn't, so just try to highlight the literal search term
478+
highlights = [ term ];
479+
}
480+
454481
self.setState({
455-
searchTerm: term,
482+
highlights: highlights,
456483
searchResults: data,
484+
searchScope: scope,
457485
});
458486
}, function(error) {
459487
var ErrorDialog = sdk.getComponent("organisms.ErrorDialog");
@@ -466,39 +494,54 @@ module.exports = {
466494

467495
getEventTiles: function() {
468496
var DateSeparator = sdk.getComponent('molecules.DateSeparator');
497+
var cli = MatrixClientPeg.get();
469498

470499
var ret = [];
471500
var count = 0;
472501

473502
var EventTile = sdk.getComponent('messages.Event');
503+
var self = this;
474504

475-
if (this.state.searchResults) {
476-
// XXX: this dance is foul, due to the results API not returning sorted results
505+
if (this.state.searchResults &&
506+
this.state.searchResults.search_categories.room_events.results &&
507+
this.state.searchResults.search_categories.room_events.groups)
508+
{
509+
// XXX: this dance is foul, due to the results API not directly returning sorted results
477510
var results = this.state.searchResults.search_categories.room_events.results;
478-
var eventIds = Object.keys(results);
479-
// XXX: todo: merge overlapping results somehow?
480-
// XXX: why doesn't searching on name work?
481-
var resultList = eventIds.map(function(key) { return results[key]; }); // .sort(function(a, b) { b.rank - a.rank });
482-
for (var i = 0; i < resultList.length; i++) {
483-
var ts1 = resultList[i].result.origin_server_ts;
484-
ret.push(<li key={ts1 + "-search"}><DateSeparator ts={ts1}/></li>); // Rank: {resultList[i].rank}
485-
var mxEv = new Matrix.MatrixEvent(resultList[i].result);
486-
if (resultList[i].context.events_before[0]) {
487-
var mxEv2 = new Matrix.MatrixEvent(resultList[i].context.events_before[0]);
488-
if (EventTile.haveTileForEvent(mxEv2)) {
489-
ret.push(<li key={mxEv.getId() + "-1"}><EventTile mxEvent={mxEv2} contextual={true} /></li>);
490-
}
491-
}
492-
if (EventTile.haveTileForEvent(mxEv)) {
493-
ret.push(<li key={mxEv.getId() + "+0"}><EventTile mxEvent={mxEv} searchTerm={this.state.searchTerm}/></li>);
511+
var roomIdGroups = this.state.searchResults.search_categories.room_events.groups.room_id;
512+
513+
Object.keys(roomIdGroups)
514+
.sort(function(a, b) { roomIdGroups[a].order - roomIdGroups[b].order }) // WHY NOT RETURN AN ORDERED ARRAY?!?!?!
515+
.forEach(function(roomId)
516+
{
517+
// XXX: todo: merge overlapping results somehow?
518+
// XXX: why doesn't searching on name work?
519+
if (self.state.searchScope === 'All') {
520+
ret.push(<li key={ roomId }><h1>Room: { cli.getRoom(roomId).name }</h1></li>);
494521
}
495-
if (resultList[i].context.events_after[0]) {
496-
var mxEv2 = new Matrix.MatrixEvent(resultList[i].context.events_after[0]);
497-
if (EventTile.haveTileForEvent(mxEv2)) {
498-
ret.push(<li key={mxEv.getId() + "+1"}><EventTile mxEvent={mxEv2} contextual={true} /></li>);
522+
523+
var resultList = roomIdGroups[roomId].results.map(function(eventId) { return results[eventId]; });
524+
for (var i = resultList.length - 1; i >= 0; i--) {
525+
var ts1 = resultList[i].result.origin_server_ts;
526+
ret.push(<li key={ts1 + "-search"}><DateSeparator ts={ts1}/></li>); // Rank: {resultList[i].rank}
527+
var mxEv = new Matrix.MatrixEvent(resultList[i].result);
528+
if (resultList[i].context.events_before[0]) {
529+
var mxEv2 = new Matrix.MatrixEvent(resultList[i].context.events_before[0]);
530+
if (EventTile.haveTileForEvent(mxEv2)) {
531+
ret.push(<li key={mxEv.getId() + "-1"}><EventTile mxEvent={mxEv2} contextual={true} /></li>);
532+
}
533+
}
534+
if (EventTile.haveTileForEvent(mxEv)) {
535+
ret.push(<li key={mxEv.getId() + "+0"}><EventTile mxEvent={mxEv} highlights={self.state.highlights}/></li>);
536+
}
537+
if (resultList[i].context.events_after[0]) {
538+
var mxEv2 = new Matrix.MatrixEvent(resultList[i].context.events_after[0]);
539+
if (EventTile.haveTileForEvent(mxEv2)) {
540+
ret.push(<li key={mxEv.getId() + "+1"}><EventTile mxEvent={mxEv2} contextual={true} /></li>);
541+
}
499542
}
500543
}
501-
}
544+
});
502545
return ret;
503546
}
504547

@@ -530,7 +573,7 @@ module.exports = {
530573
var ts0 = this.state.room.timeline[i - 1].getTs();
531574
var ts1 = this.state.room.timeline[i].getTs();
532575
if (new Date(ts0).toDateString() !== new Date(ts1).toDateString()) {
533-
dateSeparator = <DateSeparator key={ts1} ts={ts1}/>;
576+
dateSeparator = <li key={ts1}><DateSeparator key={ts1} ts={ts1}/></li>;
534577
continuation = false;
535578
}
536579
}

‎src/skins/vector/css/atoms/MemberAvatar.css‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ limitations under the License.
1515
*/
1616

1717
.mx_MemberAvatar {
18-
/* commenting this out as it breaks on FF seemingly */
19-
/* position: relative; */
18+
position: relative;
2019
}
2120

2221
.mx_MemberAvatar_initial {

‎src/skins/vector/css/common.css‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ html {
2222
}
2323

2424
body {
25-
font-family: 'Myriad Pro', Helvetica, Arial, Sans-Serif;
25+
/* Myriad Pro lacks combining diacritics, so these will fall through
26+
to the next font. Helevetica's diacritics however do not combine
27+
nicely with Myriad Pro (on OSX, at least) and result in a huge
28+
horizontal mess. Arial empirically gets it right, hence prioritising
29+
Arial here. */
30+
font-family: 'Myriad Pro', Arial, Helvetica, Sans-Serif;
2631
font-size: 16px;
2732
color: #454545;
2833
border: 0px;

‎src/skins/vector/css/molecules/EventAsTextTile.css‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ limitations under the License.
1616

1717
.mx_EventAsTextTile {
1818
opacity: 0.5;
19+
overflow-y: hidden;
1920
}

‎src/skins/vector/css/molecules/EventTile.css‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ limitations under the License.
2727
margin-left: -73px;
2828
margin-top: -4px;
2929
float: left;
30+
position: relative;
3031
}
3132

3233
.mx_EventTile_avatar img {
@@ -44,6 +45,7 @@ limitations under the License.
4445
font-size: 14px;
4546
margin-bottom: 4px;
4647
display: block;
48+
overflow-y: hidden;
4749
}
4850

4951
.mx_EventTile .mx_MessageTimestamp {
@@ -63,6 +65,7 @@ limitations under the License.
6365
.mx_MessageTile_content {
6466
display: block;
6567
margin-right: 100px;
68+
overflow-y: hidden;
6669
}
6770

6871
/* Various markdown overrides */
@@ -87,6 +90,12 @@ limitations under the License.
8790
color: #76cfa6;
8891
}
8992

93+
.mx_MessageTile_content .markdown-body .hljs {
94+
display: inherit ! important;
95+
}
96+
97+
/* end of overrides */
98+
9099
.mx_MessageTile_searchHighlight {
91100
background-color: #76cfa6;
92101
color: #fff;

‎src/skins/vector/css/molecules/MemberInfo.css‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ limitations under the License.
3737
}
3838

3939
.mx_MemberInfo_profileField {
40-
opacity: 0.6;
40+
font-color: #999999;
4141
font-size: 14px;
42+
position: relative;
43+
background-color: #fff;
4244
}
4345

4446
.mx_MemberInfo_buttons {

‎src/skins/vector/css/molecules/MemberTile.css‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,6 @@ limitations under the License.
9898
opacity: 0.25;
9999
}
100100

101-
.mx_MemberTile_zalgo {
102-
font-family: Helvetica, Arial, Sans-Serif;
103-
}
104-
105101
.mx_MemberTile:hover .mx_MessageTimestamp {
106102
display: block;
107103
}

‎src/skins/vector/css/molecules/MessageComposer.css‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ limitations under the License.
5959
box-shadow: none;
6060

6161
/* needed for FF */
62-
font-family: 'Myriad Pro', Helvetica, Arial, Sans-Serif;
62+
font-family: 'Myriad Pro', Arial, Helvetica, Sans-Serif;
6363
}
6464

6565
/* hack for FF as vertical alignment of custom placeholder text is broken */

‎src/skins/vector/css/molecules/RoomHeader.css‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ limitations under the License.
111111

112112
.mx_RoomHeader_nametext {
113113
display: inline-block;
114+
overflow-y: hidden;
114115
}
115116

116117
.mx_RoomHeader_settingsButton {

‎src/skins/vector/css/molecules/SenderProfile.css‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,3 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
17-
.mx_SenderProfile_zalgo {
18-
font-family: Helvetica, Arial, Sans-Serif;
19-
display: table-row ! important;
20-
}

0 commit comments

Comments
 (0)