Skip to content

Commit 2391c21

Browse files
committed
fix up the room directory a lot - with loading spinner, better layout, etc
1 parent f5b9f47 commit 2391c21

2 files changed

Lines changed: 49 additions & 4 deletions

File tree

‎skins/base/css/organisms/RoomDirectory.css‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,30 @@ limitations under the License.
1818
width: 720px;
1919
margin-left: auto;
2020
margin-right: auto;
21+
margin-bottom: 12px;
2122
color: #4a4a4a;
23+
24+
display: -webkit-box;
25+
display: -moz-box;
26+
display: -ms-flexbox;
27+
display: -webkit-flex;
28+
display: flex;
29+
30+
flex-direction: column;
31+
-webkit-flex-direction: column;
32+
}
33+
34+
.mx_RoomDirectory_list {
35+
flex: 1;
36+
37+
display: -webkit-box;
38+
display: -moz-box;
39+
display: -ms-flexbox;
40+
display: -webkit-flex;
41+
display: flex;
42+
43+
flex-direction: column;
44+
-webkit-flex-direction: column;
2245
}
2346

2447
.mx_RoomDirectory_input {
@@ -34,22 +57,29 @@ limitations under the License.
3457

3558
.mx_RoomDirectory_tableWrapper {
3659
overflow-y: scroll;
37-
height: 400px;
60+
flex: 1 1 0;
3861
}
3962

4063
.mx_RoomDirectory_table {
4164
width: 100%;
4265
text-align: left;
66+
table-layout: fixed;
4367
}
4468

4569
.mx_RoomDirectory_table th {
4670
font-weight: 400;
4771
font-size: 12px;
4872
}
4973

74+
.mx_RoomDirectory_table tbody {
75+
cursor: pointer;
76+
}
77+
5078
.mx_RoomDirectory_table td {
5179
font-weight: 300;
5280
font-size: 16px;
81+
overflow-x: hidden;
82+
text-overflow: ellipsis;
5383
}
5484

5585
.mx_RoomDirectory_table .mx_RoomDirectory_name {

‎skins/base/views/organisms/RoomDirectory.js‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var ErrorDialog = ComponentBroker.get("organisms/ErrorDialog");
2525
var RoomHeader = ComponentBroker.get('molecules/RoomHeader');
2626
var dis = require("../../../../src/dispatcher");
2727

28+
var Loader = require("react-loader");
2829

2930
module.exports = React.createClass({
3031
displayName: 'RoomDirectory',
@@ -33,13 +34,15 @@ module.exports = React.createClass({
3334
return {
3435
publicRooms: [],
3536
roomAlias: '',
37+
loading: true,
3638
}
3739
},
3840

3941
componentDidMount: function() {
4042
var self = this;
4143
MatrixClientPeg.get().publicRooms(function (err, data) {
4244
if (err) {
45+
self.setState({ loading: false });
4346
console.error("Failed to get publicRooms: %s", JSON.stringify(err));
4447
Modal.createDialog(ErrorDialog, {
4548
title: "Failed to get public room list",
@@ -48,14 +51,17 @@ module.exports = React.createClass({
4851
}
4952
else {
5053
self.setState({
51-
publicRooms: data.chunk
54+
publicRooms: data.chunk,
55+
loading: false,
5256
});
5357
self.forceUpdate();
5458
}
5559
});
5660
},
5761

5862
joinRoom: function(roomId) {
63+
var self = this;
64+
self.setState({ loading: true });
5965
// XXX: check that JS SDK suppresses duplicate attempts to join the same room
6066
MatrixClientPeg.get().joinRoom(roomId).done(function() {
6167
dis.dispatch({
@@ -76,14 +82,15 @@ module.exports = React.createClass({
7682

7783
var rooms = this.state.publicRooms.filter(function(a) {
7884
// FIXME: if incrementally typing, keep narrowing down the search set
85+
// incrementally rather than starting over each time.
7986
return (a.aliases[0].search(filter) >= 0 && a.num_joined_members > 0);
8087
}).sort(function(a,b) {
8188
return a.num_joined_members - b.num_joined_members;
8289
});
8390
var rows = [];
8491
var self = this;
8592
for (var i = 0; i < rooms.length; i++) {
86-
var name = rooms[i].name;
93+
var name = rooms[i].name || rooms[i].aliases[0];
8794
// <img src={ MatrixClientPeg.get().getAvatarUrlForRoom(rooms[i].room_id, 40, 40, "crop") } width="40" height="40" alt=""/>
8895
rows.unshift(
8996
<tbody key={ rooms[i].room_id }>
@@ -113,14 +120,22 @@ module.exports = React.createClass({
113120
},
114121

115122
render: function() {
123+
if (this.state.loading) {
124+
return (
125+
<div className="mx_RoomDirectory">
126+
<Loader />
127+
</div>
128+
);
129+
}
130+
116131
return (
117132
<div className="mx_RoomDirectory">
118133
<RoomHeader simpleHeader="Public Rooms" />
119134
<div className="mx_RoomDirectory_list">
120135
<input ref="roomAlias" placeholder="Join a room (e.g. #foo:domain.com)" className="mx_RoomDirectory_input" size="64" onKeyUp={ this.onKeyUp }/>
121136
<div className="mx_RoomDirectory_tableWrapper">
122137
<table className="mx_RoomDirectory_table">
123-
<tr><th>Room</th><th>Alias</th><th>Members</th></tr>
138+
<tr><th width="45%">Room</th><th width="45%">Alias</th><th width="10%">Members</th></tr>
124139
{ this.getRows(this.state.roomAlias) }
125140
</table>
126141
</div>

0 commit comments

Comments
 (0)