1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-06 12:02:40 +03:00

Revert "room name should only take canonical alias into account"

This commit is contained in:
David Baker
2018-09-20 11:20:49 +01:00
committed by GitHub
parent c2100d7622
commit a08a3078da
2 changed files with 13 additions and 5 deletions

View File

@@ -863,24 +863,24 @@ describe("Room", function() {
expect(name.indexOf(userB)).toNotEqual(-1, name);
});
it("should not show the room alias if one exists for private " +
it("should show the room alias if one exists for private " +
"(invite join_rules) rooms if a room name doesn't exist.", function() {
const alias = "#room_alias:here";
setJoinRule("invite");
setAliases([alias, "#another:one"]);
room.recalculate();
const name = room.name;
expect(name).toEqual("Empty room");
expect(name).toEqual(alias);
});
it("should not show the room alias if one exists for public " +
it("should show the room alias if one exists for public " +
"(public join_rules) rooms if a room name doesn't exist.", function() {
const alias = "#room_alias:here";
setJoinRule("public");
setAliases([alias, "#another:one"]);
room.recalculate();
const name = room.name;
expect(name).toEqual("Empty room");
expect(name).toEqual(alias);
});
it("should show the room name if one exists for private " +

View File

@@ -1525,7 +1525,15 @@ function calculateRoomName(room, userId, ignoreRoomNameEvent) {
}
}
const alias = room.getCanonicalAlias();
let alias = room.getCanonicalAlias();
if (!alias) {
const aliases = room.getAliases();
if (aliases.length) {
alias = aliases[0];
}
}
if (alias) {
return alias;
}