You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-09-03 08:42:03 +03:00
Simplify logic and layout
This commit is contained in:
@@ -415,6 +415,11 @@ function setEventMetadata(event, stateContext, toStartOfTimeline) {
|
|||||||
function calculateRoomName(room, userId) {
|
function calculateRoomName(room, userId) {
|
||||||
// check for an alias, if any. for now, assume first alias is the
|
// check for an alias, if any. for now, assume first alias is the
|
||||||
// official one.
|
// official one.
|
||||||
|
var mRoomName = room.currentState.getStateEvents('m.room.name', '');
|
||||||
|
if (mRoomName) {
|
||||||
|
return mRoomName.getContent().name;
|
||||||
|
}
|
||||||
|
|
||||||
var alias;
|
var alias;
|
||||||
var canonicalAlias = room.currentState.getStateEvents("m.room.canonical_alias", "");
|
var canonicalAlias = room.currentState.getStateEvents("m.room.canonical_alias", "");
|
||||||
if (canonicalAlias) {
|
if (canonicalAlias) {
|
||||||
@@ -427,15 +432,10 @@ function calculateRoomName(room, userId) {
|
|||||||
alias = mRoomAliases.getContent().aliases[0];
|
alias = mRoomAliases.getContent().aliases[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (alias) {
|
||||||
var mRoomName = room.currentState.getStateEvents('m.room.name', '');
|
|
||||||
if (mRoomName) {
|
|
||||||
return mRoomName.getContent().name + (false && alias ? " (" + alias + ")" : "");
|
|
||||||
}
|
|
||||||
else if (alias) {
|
|
||||||
return alias;
|
return alias;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// get members that are NOT ourselves and are actually in the room.
|
// get members that are NOT ourselves and are actually in the room.
|
||||||
var members = utils.filter(room.currentState.getMembers(), function(m) {
|
var members = utils.filter(room.currentState.getMembers(), function(m) {
|
||||||
return (m.userId !== userId && m.membership !== "leave");
|
return (m.userId !== userId && m.membership !== "leave");
|
||||||
@@ -479,7 +479,6 @@ function calculateRoomName(room, userId) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Room class.
|
* The Room class.
|
||||||
|
Reference in New Issue
Block a user