Merge pull request #314 from matrix-org/dbkr/show_canonical_alias
Show canonical alias in URL bar
This commit is contained in:
commit
1d42443c0c
2 changed files with 8 additions and 16 deletions
|
@ -16,21 +16,13 @@ limitations under the License.
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
/**
|
/**
|
||||||
* Given a room object, return the canonical alias for it
|
* Given a room object, return the alias we should use for it,
|
||||||
* if there is one. Otherwise return null;
|
* if any. This could be the canonical alias if one exists, otherwise
|
||||||
|
* an alias selected arbitrarily but deterministically from the list
|
||||||
|
* of aliases. Otherwise return null;
|
||||||
*/
|
*/
|
||||||
getCanonicalAliasForRoom: function(room) {
|
getDisplayAliasForRoom: function(room) {
|
||||||
var aliasEvents = room.currentState.getStateEvents(
|
return room.getCanonicalAlias() || room.getAliases()[0];
|
||||||
"m.room.aliases"
|
|
||||||
);
|
|
||||||
// Canonical aliases aren't implemented yet, so just return the first
|
|
||||||
for (var j = 0; j < aliasEvents.length; j++) {
|
|
||||||
var aliases = aliasEvents[j].getContent().aliases;
|
|
||||||
if (aliases && aliases.length) {
|
|
||||||
return aliases[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -539,7 +539,7 @@ module.exports = React.createClass({
|
||||||
var presentedId = roomAlias || roomId;
|
var presentedId = roomAlias || roomId;
|
||||||
var room = MatrixClientPeg.get().getRoom(roomId);
|
var room = MatrixClientPeg.get().getRoom(roomId);
|
||||||
if (room) {
|
if (room) {
|
||||||
var theAlias = MatrixTools.getCanonicalAliasForRoom(room);
|
var theAlias = MatrixTools.getDisplayAliasForRoom(room);
|
||||||
if (theAlias) presentedId = theAlias;
|
if (theAlias) presentedId = theAlias;
|
||||||
|
|
||||||
// No need to do this given RoomView triggers it itself...
|
// No need to do this given RoomView triggers it itself...
|
||||||
|
@ -631,7 +631,7 @@ module.exports = React.createClass({
|
||||||
var presentedId = self.state.currentRoomId;
|
var presentedId = self.state.currentRoomId;
|
||||||
var room = MatrixClientPeg.get().getRoom(self.state.currentRoomId);
|
var room = MatrixClientPeg.get().getRoom(self.state.currentRoomId);
|
||||||
if (room) {
|
if (room) {
|
||||||
var theAlias = MatrixTools.getCanonicalAliasForRoom(room);
|
var theAlias = MatrixTools.getDisplayAliasForRoom(room);
|
||||||
if (theAlias) presentedId = theAlias;
|
if (theAlias) presentedId = theAlias;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue