mirror of
https://mau.dev/maunium/synapse.git
synced 2024-08-28 13:11:56 +00:00
SYWEB-15: Always show the room alias as well as its name in the UI
This commit is contained in:
parent
b3a0961c6c
commit
9aed6a06cf
@ -26,72 +26,74 @@ angular.module('matrixFilter', [])
|
|||||||
// If there is an alias, use it
|
// If there is an alias, use it
|
||||||
// TODO: only one alias is managed for now
|
// TODO: only one alias is managed for now
|
||||||
var alias = matrixService.getRoomIdToAliasMapping(room_id);
|
var alias = matrixService.getRoomIdToAliasMapping(room_id);
|
||||||
if (alias) {
|
|
||||||
roomName = alias;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (undefined === roomName) {
|
var room = $rootScope.events.rooms[room_id];
|
||||||
|
if (room) {
|
||||||
|
// Get name from room state date
|
||||||
|
var room_name_event = room["m.room.name"];
|
||||||
|
if (room_name_event) {
|
||||||
|
roomName = room_name_event.content.name;
|
||||||
|
}
|
||||||
|
else if (alias) {
|
||||||
|
roomName = alias;
|
||||||
|
}
|
||||||
|
else if (room.members) {
|
||||||
|
// Else, build the name from its users
|
||||||
|
// FIXME: Is it still required?
|
||||||
|
// Limit the room renaming to 1:1 room
|
||||||
|
if (2 === Object.keys(room.members).length) {
|
||||||
|
for (var i in room.members) {
|
||||||
|
var member = room.members[i];
|
||||||
|
if (member.state_key !== matrixService.config().user_id) {
|
||||||
|
|
||||||
var room = $rootScope.events.rooms[room_id];
|
if (member.state_key in $rootScope.presence) {
|
||||||
if (room) {
|
// If the user is available in presence, use the displayname there
|
||||||
// Get name from room state date
|
// as it is the most uptodate
|
||||||
var room_name_event = room["m.room.name"];
|
roomName = $rootScope.presence[member.state_key].content.displayname;
|
||||||
if (room_name_event) {
|
}
|
||||||
roomName = room_name_event.content.name;
|
else if (member.content.displayname) {
|
||||||
}
|
roomName = member.content.displayname;
|
||||||
else if (room.members) {
|
}
|
||||||
// Else, build the name from its users
|
else {
|
||||||
// FIXME: Is it still required?
|
roomName = member.state_key;
|
||||||
// Limit the room renaming to 1:1 room
|
|
||||||
if (2 === Object.keys(room.members).length) {
|
|
||||||
for (var i in room.members) {
|
|
||||||
var member = room.members[i];
|
|
||||||
if (member.state_key !== matrixService.config().user_id) {
|
|
||||||
|
|
||||||
if (member.state_key in $rootScope.presence) {
|
|
||||||
// If the user is available in presence, use the displayname there
|
|
||||||
// as it is the most uptodate
|
|
||||||
roomName = $rootScope.presence[member.state_key].content.displayname;
|
|
||||||
}
|
|
||||||
else if (member.content.displayname) {
|
|
||||||
roomName = member.content.displayname;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
roomName = member.state_key;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (1 === Object.keys(room.members).length) {
|
}
|
||||||
// The other member may be in the invite list, get all invited users
|
else if (1 === Object.keys(room.members).length) {
|
||||||
var invitedUserIDs = [];
|
// The other member may be in the invite list, get all invited users
|
||||||
for (var i in room.messages) {
|
var invitedUserIDs = [];
|
||||||
var message = room.messages[i];
|
for (var i in room.messages) {
|
||||||
if ("m.room.member" === message.type && "invite" === message.membership) {
|
var message = room.messages[i];
|
||||||
// Make sure there is no duplicate user
|
if ("m.room.member" === message.type && "invite" === message.membership) {
|
||||||
if (-1 === invitedUserIDs.indexOf(message.state_key)) {
|
// Make sure there is no duplicate user
|
||||||
invitedUserIDs.push(message.state_key);
|
if (-1 === invitedUserIDs.indexOf(message.state_key)) {
|
||||||
}
|
invitedUserIDs.push(message.state_key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// For now, only 1:1 room needs to be renamed. It means only 1 invited user
|
|
||||||
if (1 === invitedUserIDs.length) {
|
|
||||||
var userID = invitedUserIDs[0];
|
|
||||||
|
|
||||||
// Try to resolve his displayname in presence global data
|
// For now, only 1:1 room needs to be renamed. It means only 1 invited user
|
||||||
if (userID in $rootScope.presence) {
|
if (1 === invitedUserIDs.length) {
|
||||||
roomName = $rootScope.presence[userID].content.displayname;
|
var userID = invitedUserIDs[0];
|
||||||
}
|
|
||||||
else {
|
// Try to resolve his displayname in presence global data
|
||||||
roomName = userID;
|
if (userID in $rootScope.presence) {
|
||||||
}
|
roomName = $rootScope.presence[userID].content.displayname;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
roomName = userID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Always show the alias in the room displayed name
|
||||||
|
if (roomName && alias && alias !== roomName) {
|
||||||
|
roomName += " (" + alias + ")";
|
||||||
|
}
|
||||||
|
|
||||||
if (undefined === roomName) {
|
if (undefined === roomName) {
|
||||||
// By default, use the room ID
|
// By default, use the room ID
|
||||||
roomName = room_id;
|
roomName = room_id;
|
||||||
|
Loading…
Reference in New Issue
Block a user