Skip to content

Commit

Permalink
Merge pull request #738 from matrix-org/revert-733-bwindels/roomnamea…
Browse files Browse the repository at this point in the history
…lias

Revert "room name should only take canonical alias into account"
  • Loading branch information
bwindels authored Sep 20, 2018
2 parents c2100d7 + a08a307 commit 184c3dc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 4 additions & 4 deletions spec/unit/room.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 " +
Expand Down
10 changes: 9 additions & 1 deletion src/models/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 184c3dc

Please sign in to comment.