From a08a3078dae5da90f5a2edbf380a8bbbbff44b28 Mon Sep 17 00:00:00 2001 From: David Baker Date: Thu, 20 Sep 2018 11:20:49 +0100 Subject: [PATCH] Revert "room name should only take canonical alias into account" --- spec/unit/room.spec.js | 8 ++++---- src/models/room.js | 10 +++++++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/spec/unit/room.spec.js b/spec/unit/room.spec.js index 6aac5162664..4a8ea7e5980 100644 --- a/spec/unit/room.spec.js +++ b/spec/unit/room.spec.js @@ -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 " + diff --git a/src/models/room.js b/src/models/room.js index fd9fcc044f1..c99d87ba501 100644 --- a/src/models/room.js +++ b/src/models/room.js @@ -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; }