From 737cadaabce91fd6165789c93bfc6109d0f8edc6 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 8 Mar 2021 18:13:14 -0700 Subject: [PATCH 1/2] Add a function to get a room's MXC URI This matches the RoomMember function of the same name. --- src/models/room.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/models/room.js b/src/models/room.js index 9c321e1bb..9abdf2723 100644 --- a/src/models/room.js +++ b/src/models/room.js @@ -836,6 +836,15 @@ Room.prototype.getAvatarUrl = function(baseUrl, width, height, resizeMethod, return null; }; +/** + * Get the mxc avatar url for the room, if one was set. + * @return {string} the mxc avatar url or falsy + */ +Room.prototype.getMxcAvatarUrl = function() { + const roomAvatarEvent = this.currentState.getStateEvents("m.room.avatar", ""); + return roomAvatarEvent ? roomAvatarEvent.getContent().url : null; +} + /** * Get the aliases this room has according to the room's state * The aliases returned by this function may not necessarily From 0ff611e033839dfb7e09ad12a20b5fced50a3b5d Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 8 Mar 2021 18:16:39 -0700 Subject: [PATCH 2/2] Enum and linter --- src/models/room.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/models/room.js b/src/models/room.js index 9abdf2723..1f19cf198 100644 --- a/src/models/room.js +++ b/src/models/room.js @@ -818,7 +818,7 @@ Room.prototype.getBlacklistUnverifiedDevices = function() { */ Room.prototype.getAvatarUrl = function(baseUrl, width, height, resizeMethod, allowDefault) { - const roomAvatarEvent = this.currentState.getStateEvents("m.room.avatar", ""); + const roomAvatarEvent = this.currentState.getStateEvents(EventType.RoomAvatar, ""); if (allowDefault === undefined) { allowDefault = true; } @@ -841,9 +841,9 @@ Room.prototype.getAvatarUrl = function(baseUrl, width, height, resizeMethod, * @return {string} the mxc avatar url or falsy */ Room.prototype.getMxcAvatarUrl = function() { - const roomAvatarEvent = this.currentState.getStateEvents("m.room.avatar", ""); + const roomAvatarEvent = this.currentState.getStateEvents(EventType.RoomAvatar, ""); return roomAvatarEvent ? roomAvatarEvent.getContent().url : null; -} +}; /** * Get the aliases this room has according to the room's state