2015-07-21 06:11:24 +03:00
|
|
|
/*
|
2016-01-07 07:17:56 +03:00
|
|
|
Copyright 2015, 2016 OpenMarket Ltd
|
2015-07-21 06:11:24 +03:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var React = require('react');
|
|
|
|
|
2015-09-22 21:09:23 +03:00
|
|
|
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
|
2016-02-20 16:36:48 +03:00
|
|
|
var ContentRepo = require("matrix-js-sdk").ContentRepo;
|
2015-09-22 21:09:23 +03:00
|
|
|
var Modal = require('matrix-react-sdk/lib/Modal');
|
2016-05-18 17:01:36 +03:00
|
|
|
var sdk = require('matrix-react-sdk');
|
2015-09-22 21:09:23 +03:00
|
|
|
var dis = require('matrix-react-sdk/lib/dispatcher');
|
2016-02-22 12:35:11 +03:00
|
|
|
var GeminiScrollbar = require('react-gemini-scrollbar');
|
2015-07-21 06:11:24 +03:00
|
|
|
|
2016-02-20 16:36:48 +03:00
|
|
|
var linkify = require('linkifyjs');
|
2016-02-21 02:54:47 +03:00
|
|
|
var linkifyString = require('linkifyjs/string');
|
2016-02-20 16:36:48 +03:00
|
|
|
var linkifyMatrix = require('matrix-react-sdk/lib/linkify-matrix');
|
2016-02-21 02:54:47 +03:00
|
|
|
var sanitizeHtml = require('sanitize-html');
|
2016-09-16 19:33:28 +03:00
|
|
|
var q = require('q');
|
2016-02-20 16:36:48 +03:00
|
|
|
|
|
|
|
linkifyMatrix(linkify);
|
|
|
|
|
2015-07-21 06:11:24 +03:00
|
|
|
module.exports = React.createClass({
|
|
|
|
displayName: 'RoomDirectory',
|
|
|
|
|
2016-09-15 19:20:13 +03:00
|
|
|
propTypes: {
|
|
|
|
config: React.PropTypes.object,
|
|
|
|
},
|
|
|
|
|
|
|
|
getDefaultProps: function() {
|
|
|
|
return {
|
|
|
|
config: {
|
|
|
|
networks: [],
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-07-21 06:11:24 +03:00
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
|
|
|
publicRooms: [],
|
2015-07-28 00:31:24 +03:00
|
|
|
loading: true,
|
2016-09-15 17:18:12 +03:00
|
|
|
filterByNetwork: null,
|
2015-07-21 06:11:24 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-04-15 20:29:57 +03:00
|
|
|
componentWillMount: function() {
|
2016-09-15 19:20:13 +03:00
|
|
|
// precompile Regexps
|
|
|
|
this.networkPatterns = {};
|
|
|
|
if (this.props.config.networkPatterns) {
|
|
|
|
for (const network of Object.keys(this.props.config.networkPatterns)) {
|
|
|
|
this.networkPatterns[network] = new RegExp(this.props.config.networkPatterns[network]);
|
|
|
|
}
|
|
|
|
}
|
2016-09-16 19:33:28 +03:00
|
|
|
this.nextBatch = null;
|
|
|
|
this.filterString = null;
|
2016-09-16 20:53:18 +03:00
|
|
|
this.filterTimeout = null;
|
2016-09-16 21:59:06 +03:00
|
|
|
this.scrollPanel = null;
|
2016-09-23 15:48:44 +03:00
|
|
|
this.searchBox = null;
|
2016-09-15 19:20:13 +03:00
|
|
|
|
2016-04-15 20:29:57 +03:00
|
|
|
// dis.dispatch({
|
|
|
|
// action: 'ui_opacity',
|
|
|
|
// sideOpacity: 0.3,
|
|
|
|
// middleOpacity: 0.3,
|
|
|
|
// });
|
|
|
|
},
|
|
|
|
|
2015-07-21 06:11:24 +03:00
|
|
|
componentDidMount: function() {
|
2016-09-16 19:33:28 +03:00
|
|
|
this.refreshRoomList();
|
2016-06-21 18:47:40 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
componentWillUnmount: function() {
|
|
|
|
// dis.dispatch({
|
|
|
|
// action: 'ui_opacity',
|
|
|
|
// sideOpacity: 1.0,
|
|
|
|
// middleOpacity: 1.0,
|
|
|
|
// });
|
|
|
|
},
|
|
|
|
|
2016-09-16 19:33:28 +03:00
|
|
|
refreshRoomList: function() {
|
|
|
|
this.nextBatch = null;
|
|
|
|
this.setState({
|
|
|
|
publicRooms: [],
|
2016-09-16 21:29:56 +03:00
|
|
|
loading: true,
|
2016-09-16 19:33:28 +03:00
|
|
|
});
|
|
|
|
this.getMoreRooms().done();
|
|
|
|
},
|
|
|
|
|
|
|
|
getMoreRooms: function() {
|
2016-09-16 20:48:47 +03:00
|
|
|
const my_filter_string = this.filterString;
|
2016-09-16 19:33:28 +03:00
|
|
|
const opts = {limit: 20};
|
|
|
|
if (this.nextBatch) opts.since = this.nextBatch;
|
2016-09-16 20:48:47 +03:00
|
|
|
if (this.filterString) opts.filter = { generic_search_term: my_filter_string } ;
|
2016-09-16 19:33:28 +03:00
|
|
|
return MatrixClientPeg.get().publicRooms(opts).then((data) => {
|
2016-09-16 20:48:47 +03:00
|
|
|
if (my_filter_string != this.filterString) {
|
|
|
|
// if the filter has changed since this request was sent,
|
|
|
|
// throw away the result (don't even clear the busy flag
|
|
|
|
// since we must still have a request in flight)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-16 19:33:28 +03:00
|
|
|
this.nextBatch = data.next_batch;
|
|
|
|
this.setState((s) => {
|
|
|
|
s.publicRooms.push(...data.chunk);
|
|
|
|
s.loading = false;
|
|
|
|
return s;
|
|
|
|
});
|
|
|
|
return Boolean(data.next_batch);
|
|
|
|
}, (err) => {
|
2016-09-16 20:48:47 +03:00
|
|
|
if (my_filter_string != this.filterString) {
|
|
|
|
// as above: we don't care about errors for old
|
|
|
|
// requests either
|
|
|
|
return;
|
|
|
|
}
|
2016-09-16 19:33:28 +03:00
|
|
|
this.setState({ loading: false });
|
|
|
|
console.error("Failed to get publicRooms: %s", JSON.stringify(err));
|
|
|
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
|
|
|
Modal.createDialog(ErrorDialog, {
|
|
|
|
title: "Failed to get public room list",
|
|
|
|
description: err.message
|
|
|
|
});
|
2015-07-21 06:11:24 +03:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2016-06-22 16:52:55 +03:00
|
|
|
/**
|
|
|
|
* A limited interface for removing rooms from the directory.
|
|
|
|
* Will set the room to not be publicly visible and delete the
|
|
|
|
* default alias. In the long term, it would be better to allow
|
|
|
|
* HS admins to do this through the RoomSettings interface, but
|
|
|
|
* this needs SPEC-417.
|
|
|
|
*/
|
|
|
|
removeFromDirectory: function(room) {
|
|
|
|
var alias = get_display_alias_for_room(room);
|
|
|
|
var name = room.name || alias || "Unnamed room";
|
2016-04-15 20:29:57 +03:00
|
|
|
|
2016-06-21 18:47:40 +03:00
|
|
|
var QuestionDialog = sdk.getComponent("dialogs.QuestionDialog");
|
|
|
|
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
2016-06-22 16:52:55 +03:00
|
|
|
|
2016-06-23 13:12:25 +03:00
|
|
|
var desc;
|
|
|
|
if (alias) {
|
|
|
|
desc = `Delete the room alias '${alias}' and remove '${name}' from the directory?`;
|
|
|
|
} else {
|
|
|
|
desc = `Remove '${name}' from the directory?`;
|
|
|
|
}
|
|
|
|
|
2016-06-21 18:47:40 +03:00
|
|
|
Modal.createDialog(QuestionDialog, {
|
2016-06-22 16:52:55 +03:00
|
|
|
title: "Remove from Directory",
|
2016-06-23 13:12:25 +03:00
|
|
|
description: desc,
|
2016-06-21 18:47:40 +03:00
|
|
|
onFinished: (should_delete) => {
|
2016-06-22 16:52:55 +03:00
|
|
|
if (!should_delete) return;
|
|
|
|
|
|
|
|
var Loader = sdk.getComponent("elements.Spinner");
|
|
|
|
var modal = Modal.createDialog(Loader);
|
|
|
|
var step = `remove '${name}' from the directory.`;
|
|
|
|
|
|
|
|
MatrixClientPeg.get().setRoomDirectoryVisibility(room.room_id, 'private').then(() => {
|
2016-06-23 13:12:25 +03:00
|
|
|
if (!alias) return;
|
2016-06-22 16:52:55 +03:00
|
|
|
step = 'delete the alias.';
|
2016-06-22 18:20:06 +03:00
|
|
|
return MatrixClientPeg.get().deleteAlias(alias);
|
2016-06-22 16:52:55 +03:00
|
|
|
}).done(() => {
|
|
|
|
modal.close();
|
2016-09-16 19:33:28 +03:00
|
|
|
this.refreshRoomList();
|
2016-06-22 16:52:55 +03:00
|
|
|
}, function(err) {
|
|
|
|
modal.close();
|
2016-09-16 19:33:28 +03:00
|
|
|
this.refreshRoomList();
|
2016-06-22 16:52:55 +03:00
|
|
|
Modal.createDialog(ErrorDialog, {
|
|
|
|
title: "Failed to "+step,
|
|
|
|
description: err.toString()
|
2016-06-21 18:47:40 +03:00
|
|
|
});
|
2016-06-22 16:52:55 +03:00
|
|
|
});
|
2016-03-02 17:24:00 +03:00
|
|
|
}
|
2016-06-21 18:47:40 +03:00
|
|
|
});
|
2016-04-15 20:29:57 +03:00
|
|
|
},
|
|
|
|
|
2016-06-23 12:11:46 +03:00
|
|
|
onRoomClicked: function(room, ev) {
|
2016-06-21 18:47:40 +03:00
|
|
|
if (ev.shiftKey) {
|
|
|
|
ev.preventDefault();
|
2016-06-22 16:52:55 +03:00
|
|
|
this.removeFromDirectory(room);
|
2016-06-23 12:11:46 +03:00
|
|
|
} else {
|
|
|
|
this.showRoom(room);
|
2016-03-02 17:24:00 +03:00
|
|
|
}
|
2016-06-23 12:11:46 +03:00
|
|
|
},
|
2016-06-21 18:47:40 +03:00
|
|
|
|
2016-09-15 17:18:12 +03:00
|
|
|
onNetworkChange: function(network) {
|
|
|
|
this.setState({
|
|
|
|
filterByNetwork: network,
|
2016-09-16 21:59:06 +03:00
|
|
|
}, () => {
|
|
|
|
// we just filtered out a bunch of rooms, so check to see if
|
|
|
|
// we need to fill up the scrollpanel again
|
|
|
|
// NB. Because we filter the results, the HS can keep giving
|
|
|
|
// us more rooms and we'll keep requesting more if none match
|
|
|
|
// the filter, which is pretty terrible. We need a way
|
|
|
|
// to filter by network on the server.
|
|
|
|
if (this.scrollPanel) this.scrollPanel.checkFillState();
|
2016-09-15 17:18:12 +03:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2016-09-16 19:33:28 +03:00
|
|
|
onFillRequest: function(backwards) {
|
|
|
|
if (backwards || !this.nextBatch) return q(false);
|
|
|
|
|
|
|
|
return this.getMoreRooms();
|
|
|
|
},
|
|
|
|
|
2016-09-23 15:48:44 +03:00
|
|
|
onFilterChange: function(alias) {
|
2016-09-16 22:56:14 +03:00
|
|
|
this.filterString = alias || null;
|
|
|
|
|
|
|
|
// don't send the request for a little bit,
|
|
|
|
// no point hammering the server with a
|
|
|
|
// request for every keystroke, let the
|
|
|
|
// user finish typing.
|
|
|
|
if (this.filterTimeout) {
|
|
|
|
clearTimeout(this.filterTimeout);
|
|
|
|
}
|
|
|
|
this.filterTimeout = setTimeout(() => {
|
|
|
|
this.filterTimeout = null;
|
|
|
|
this.refreshRoomList();
|
|
|
|
}, 300);
|
|
|
|
},
|
|
|
|
|
2016-09-23 17:25:13 +03:00
|
|
|
onFilterClear: function() {
|
2016-09-23 15:48:44 +03:00
|
|
|
this.filterString = null;
|
|
|
|
|
|
|
|
if (this.filterTimeout) {
|
|
|
|
clearTimeout(this.filterTimeout);
|
2016-09-16 19:33:28 +03:00
|
|
|
}
|
2016-09-23 15:48:44 +03:00
|
|
|
// update immediately
|
|
|
|
this.refreshRoomList();
|
|
|
|
},
|
|
|
|
|
|
|
|
onJoinClick: function(alias) {
|
|
|
|
this.showRoomAlias(alias);
|
|
|
|
},
|
|
|
|
|
|
|
|
collectSearchBox: function(e) {
|
|
|
|
this.searchBox = e;
|
2016-09-16 19:33:28 +03:00
|
|
|
},
|
|
|
|
|
2016-06-23 12:11:46 +03:00
|
|
|
showRoomAlias: function(alias) {
|
|
|
|
this.showRoom(null, alias);
|
|
|
|
},
|
|
|
|
|
|
|
|
showRoom: function(room, room_alias) {
|
|
|
|
var payload = {action: 'view_room'};
|
2016-03-02 17:24:00 +03:00
|
|
|
if (room) {
|
2016-06-23 12:11:46 +03:00
|
|
|
// Don't let the user view a room they won't be able to either
|
|
|
|
// peek or join: fail earlier so they don't have to click back
|
|
|
|
// to the directory.
|
2016-04-13 15:33:16 +03:00
|
|
|
if (MatrixClientPeg.get().isGuest()) {
|
|
|
|
if (!room.world_readable && !room.guest_can_join) {
|
|
|
|
var NeedToRegisterDialog = sdk.getComponent("dialogs.NeedToRegisterDialog");
|
|
|
|
Modal.createDialog(NeedToRegisterDialog, {
|
|
|
|
title: "Failed to join the room",
|
|
|
|
description: "This room is inaccessible to guests. You may be able to join if you register."
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-23 12:11:46 +03:00
|
|
|
if (!room_alias) {
|
|
|
|
room_alias = get_display_alias_for_room(room);
|
|
|
|
}
|
2016-06-22 16:52:55 +03:00
|
|
|
|
2016-06-23 12:11:46 +03:00
|
|
|
payload.oob_data = {
|
2016-03-02 17:24:00 +03:00
|
|
|
avatarUrl: room.avatar_url,
|
|
|
|
// XXX: This logic is duplicated from the JS SDK which
|
|
|
|
// would normally decide what the name is.
|
2016-06-23 12:11:46 +03:00
|
|
|
name: room.name || room_alias || "Unnamed room",
|
2016-03-02 17:24:00 +03:00
|
|
|
};
|
|
|
|
}
|
2016-06-14 15:02:34 +03:00
|
|
|
// It's not really possible to join Matrix rooms by ID because the HS has no way to know
|
|
|
|
// which servers to start querying. However, there's no other way to join rooms in
|
|
|
|
// this list without aliases at present, so if roomAlias isn't set here we have no
|
|
|
|
// choice but to supply the ID.
|
2016-06-22 16:52:55 +03:00
|
|
|
if (room_alias) {
|
|
|
|
payload.room_alias = room_alias;
|
2016-06-14 15:02:34 +03:00
|
|
|
} else {
|
2016-06-22 16:52:55 +03:00
|
|
|
payload.room_id = room.room_id;
|
2016-06-14 15:02:34 +03:00
|
|
|
}
|
|
|
|
dis.dispatch(payload);
|
2015-07-21 06:11:24 +03:00
|
|
|
},
|
|
|
|
|
2016-09-16 19:33:28 +03:00
|
|
|
getRows: function() {
|
2016-02-20 16:36:48 +03:00
|
|
|
var BaseAvatar = sdk.getComponent('avatars.BaseAvatar');
|
|
|
|
|
2015-07-21 06:11:24 +03:00
|
|
|
if (!this.state.publicRooms) return [];
|
|
|
|
|
2016-09-15 17:18:12 +03:00
|
|
|
var rooms = this.state.publicRooms.filter((a) => {
|
|
|
|
if (this.state.filterByNetwork) {
|
2016-09-15 20:56:04 +03:00
|
|
|
if (!this._isRoomInNetwork(a, this.state.filterByNetwork)) return false;
|
2016-09-15 17:18:12 +03:00
|
|
|
}
|
|
|
|
|
2016-09-16 19:33:28 +03:00
|
|
|
return true;
|
2015-07-21 06:11:24 +03:00
|
|
|
});
|
|
|
|
var rows = [];
|
|
|
|
var self = this;
|
2016-01-18 20:37:13 +03:00
|
|
|
var guestRead, guestJoin, perms;
|
2015-07-21 06:11:24 +03:00
|
|
|
for (var i = 0; i < rooms.length; i++) {
|
2016-06-22 16:52:55 +03:00
|
|
|
var name = rooms[i].name || get_display_alias_for_room(rooms[i]) || "Unnamed room";
|
2016-01-07 17:43:12 +03:00
|
|
|
guestRead = null;
|
|
|
|
guestJoin = null;
|
|
|
|
|
|
|
|
if (rooms[i].world_readable) {
|
|
|
|
guestRead = (
|
2016-02-20 16:36:48 +03:00
|
|
|
<div className="mx_RoomDirectory_perm">World readable</div>
|
2016-01-07 17:43:12 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
if (rooms[i].guest_can_join) {
|
|
|
|
guestJoin = (
|
2016-02-20 16:36:48 +03:00
|
|
|
<div className="mx_RoomDirectory_perm">Guests can join</div>
|
2016-01-07 17:43:12 +03:00
|
|
|
);
|
2016-01-18 20:37:13 +03:00
|
|
|
}
|
2016-03-15 21:38:24 +03:00
|
|
|
|
2016-01-18 20:37:13 +03:00
|
|
|
perms = null;
|
|
|
|
if (guestRead || guestJoin) {
|
2016-02-20 16:36:48 +03:00
|
|
|
perms = <div className="mx_RoomDirectory_perms">{guestRead} {guestJoin}</div>;
|
2016-01-07 17:43:12 +03:00
|
|
|
}
|
|
|
|
|
2016-02-21 02:54:47 +03:00
|
|
|
var topic = rooms[i].topic || '';
|
|
|
|
topic = linkifyString(sanitizeHtml(topic));
|
|
|
|
|
2016-09-16 19:33:28 +03:00
|
|
|
rows.push(
|
2016-06-21 18:47:40 +03:00
|
|
|
<tr key={ rooms[i].room_id }
|
2016-06-23 12:11:46 +03:00
|
|
|
onClick={self.onRoomClicked.bind(self, rooms[i])}
|
2016-06-21 18:47:40 +03:00
|
|
|
// cancel onMouseDown otherwise shift-clicking highlights text
|
|
|
|
onMouseDown={(ev) => {ev.preventDefault();}}
|
|
|
|
>
|
2016-02-20 16:36:48 +03:00
|
|
|
<td className="mx_RoomDirectory_roomAvatar">
|
|
|
|
<BaseAvatar width={24} height={24} resizeMethod='crop'
|
|
|
|
name={ name } idName={ name }
|
|
|
|
url={ ContentRepo.getHttpUriForMxc(
|
|
|
|
MatrixClientPeg.get().getHomeserverUrl(),
|
|
|
|
rooms[i].avatar_url, 24, 24, "crop") } />
|
|
|
|
</td>
|
|
|
|
<td className="mx_RoomDirectory_roomDescription">
|
|
|
|
<div className="mx_RoomDirectory_name">{ name }</div>
|
|
|
|
{ perms }
|
2016-02-21 02:54:47 +03:00
|
|
|
<div className="mx_RoomDirectory_topic"
|
|
|
|
onClick={ function(e) { e.stopPropagation() } }
|
|
|
|
dangerouslySetInnerHTML={{ __html: topic }}/>
|
2016-06-22 16:52:55 +03:00
|
|
|
<div className="mx_RoomDirectory_alias">{ get_display_alias_for_room(rooms[i]) }</div>
|
2016-02-20 16:36:48 +03:00
|
|
|
</td>
|
|
|
|
<td className="mx_RoomDirectory_roomMemberCount">
|
|
|
|
{ rooms[i].num_joined_members }
|
|
|
|
</td>
|
|
|
|
</tr>
|
2015-07-21 06:11:24 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return rows;
|
|
|
|
},
|
|
|
|
|
2016-09-16 21:59:06 +03:00
|
|
|
collectScrollPanel: function(element) {
|
|
|
|
this.scrollPanel = element;
|
|
|
|
},
|
|
|
|
|
2016-09-15 17:18:12 +03:00
|
|
|
/**
|
|
|
|
* Terrible temporary function that guess what network a public room
|
|
|
|
* entry is in, until synapse is able to tell us
|
|
|
|
*/
|
2016-09-15 20:56:04 +03:00
|
|
|
_isRoomInNetwork(room, network) {
|
|
|
|
if (room.aliases && this.networkPatterns[network]) {
|
2016-09-15 17:18:12 +03:00
|
|
|
for (const alias of room.aliases) {
|
2016-09-15 20:56:04 +03:00
|
|
|
if (this.networkPatterns[network].test(alias)) return true;
|
2016-09-15 17:18:12 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-15 20:56:04 +03:00
|
|
|
return false;
|
2016-09-15 17:18:12 +03:00
|
|
|
},
|
|
|
|
|
2015-07-21 06:11:24 +03:00
|
|
|
render: function() {
|
2016-09-16 20:41:29 +03:00
|
|
|
let content;
|
2015-07-28 00:31:24 +03:00
|
|
|
if (this.state.loading) {
|
2016-09-16 20:41:29 +03:00
|
|
|
const Loader = sdk.getComponent("elements.Spinner");
|
|
|
|
content = <div className="mx_RoomDirectory">
|
|
|
|
<Loader />
|
|
|
|
</div>;
|
|
|
|
} else {
|
|
|
|
const ScrollPanel = sdk.getComponent("structures.ScrollPanel");
|
2016-09-16 21:59:06 +03:00
|
|
|
content = <ScrollPanel ref={this.collectScrollPanel}
|
2016-09-16 20:41:29 +03:00
|
|
|
className="mx_RoomDirectory_tableWrapper"
|
|
|
|
onFillRequest={ this.onFillRequest }
|
|
|
|
stickyBottom={false}
|
|
|
|
startAtBottom={false}
|
|
|
|
onResize={function(){}}
|
|
|
|
>
|
|
|
|
<table ref="directory_table" className="mx_RoomDirectory_table">
|
|
|
|
<tbody>
|
|
|
|
{ this.getRows() }
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</ScrollPanel>;
|
2015-07-28 00:31:24 +03:00
|
|
|
}
|
|
|
|
|
2016-09-15 13:29:27 +03:00
|
|
|
const SimpleRoomHeader = sdk.getComponent('rooms.SimpleRoomHeader');
|
|
|
|
const NetworkDropdown = sdk.getComponent('directory.NetworkDropdown');
|
2016-09-23 15:48:44 +03:00
|
|
|
const DirectorySearchBox = sdk.getComponent('elements.DirectorySearchBox');
|
2015-07-21 06:11:24 +03:00
|
|
|
return (
|
|
|
|
<div className="mx_RoomDirectory">
|
2016-03-30 01:25:26 +03:00
|
|
|
<SimpleRoomHeader title="Directory" />
|
2015-07-21 06:11:24 +03:00
|
|
|
<div className="mx_RoomDirectory_list">
|
2016-09-15 13:29:27 +03:00
|
|
|
<div className="mx_RoomDirectory_listheader">
|
2016-09-23 15:48:44 +03:00
|
|
|
<DirectorySearchBox
|
|
|
|
className="mx_RoomDirectory_searchbox" ref={this.collectSearchBox}
|
|
|
|
onChange={this.onFilterChange} onClear={this.onFilterClear} onJoinClick={this.onJoinClick}
|
2016-09-16 19:33:28 +03:00
|
|
|
/>
|
2016-09-15 19:20:13 +03:00
|
|
|
<NetworkDropdown config={this.props.config} onNetworkChange={this.onNetworkChange} />
|
2016-09-15 13:29:27 +03:00
|
|
|
</div>
|
2016-09-16 20:41:29 +03:00
|
|
|
{content}
|
2015-07-21 06:11:24 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2016-06-22 16:52:55 +03:00
|
|
|
|
|
|
|
// Similar to matrix-react-sdk's MatrixTools.getDisplayAliasForRoom
|
|
|
|
// but works with the objects we get from the public room list
|
|
|
|
function get_display_alias_for_room(room) {
|
|
|
|
return room.canonical_alias || (room.aliases ? room.aliases[0] : "");
|
|
|
|
}
|