1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-09-01 21:21:58 +03:00

Simplify logic and layout

This commit is contained in:
Daniel Wagner-Hall
2015-10-30 14:58:59 +00:00
parent 83c53f6a79
commit 11f052bcc6

View File

@@ -415,6 +415,11 @@ function setEventMetadata(event, stateContext, toStartOfTimeline) {
function calculateRoomName(room, userId) {
// check for an alias, if any. for now, assume first alias is the
// official one.
var mRoomName = room.currentState.getStateEvents('m.room.name', '');
if (mRoomName) {
return mRoomName.getContent().name;
}
var alias;
var canonicalAlias = room.currentState.getStateEvents("m.room.canonical_alias", "");
if (canonicalAlias) {
@@ -427,15 +432,10 @@ function calculateRoomName(room, userId) {
alias = mRoomAliases.getContent().aliases[0];
}
}
var mRoomName = room.currentState.getStateEvents('m.room.name', '');
if (mRoomName) {
return mRoomName.getContent().name + (false && alias ? " (" + alias + ")" : "");
}
else if (alias) {
if (alias) {
return alias;
}
else {
// get members that are NOT ourselves and are actually in the room.
var members = utils.filter(room.currentState.getMembers(), function(m) {
return (m.userId !== userId && m.membership !== "leave");
@@ -478,7 +478,6 @@ function calculateRoomName(room, userId) {
members[0].name + " and " + (members.length - 1) + " others"
);
}
}
}
/**