Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 66a6f9d

Browse files
authored
Merge pull request #2438 from Half-Shot/hs/trim-back-lines
Limit line length in the room directory
2 parents ee65332 + cb5ad8d commit 66a6f9d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/components/structures/RoomDirectory.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ import { _t } from '../../languageHandler';
3434

3535
import {instanceForInstanceId, protocolNameForInstanceId} from '../../utils/DirectoryUtils';
3636

37+
const MAX_NAME_LENGTH = 80;
38+
const MAX_TOPIC_LENGTH = 160;
39+
3740
linkifyMatrix(linkify);
3841

3942
module.exports = React.createClass({
@@ -390,7 +393,6 @@ module.exports = React.createClass({
390393
const self = this;
391394
let guestRead; let guestJoin; let perms;
392395
for (let i = 0; i < rooms.length; i++) {
393-
const name = rooms[i].name || get_display_alias_for_room(rooms[i]) || _t('Unnamed room');
394396
guestRead = null;
395397
guestJoin = null;
396398

@@ -410,7 +412,15 @@ module.exports = React.createClass({
410412
perms = <div className="mx_RoomDirectory_perms">{guestRead}{guestJoin}</div>;
411413
}
412414

415+
let name = rooms[i].name || get_display_alias_for_room(rooms[i]) || _t('Unnamed room');
416+
if (name.length > MAX_NAME_LENGTH) {
417+
name = `${name.substring(0, MAX_NAME_LENGTH)}...`;
418+
}
419+
413420
let topic = rooms[i].topic || '';
421+
if (topic.length > MAX_TOPIC_LENGTH) {
422+
topic = `${topic.substring(0, MAX_TOPIC_LENGTH)}...`;
423+
}
414424
topic = linkifyString(sanitizeHtml(topic));
415425

416426
rows.push(

0 commit comments

Comments
 (0)