Bug 1347533 - Show room names instead of room IDs in Matrix. r=clokep
authorKhushil Mistry <khushil324@gmail.com>
Sat, 11 Apr 2020 13:51:47 +0300
changeset 38774 9ee88b4972cc4f30710e21bb2be4ad3fc7c0faeb
parent 38773 9320f207dba3ae3c5a8d9c5429ad32bc2d4fa32c
child 38775 055a8b65c4af34dd1db68469755105ee4ae926e1
push id401
push userclokep@gmail.com
push dateMon, 01 Jun 2020 20:41:59 +0000
reviewersclokep
bugs1347533
Bug 1347533 - Show room names instead of room IDs in Matrix. r=clokep
chat/protocols/matrix/matrix.jsm
--- a/chat/protocols/matrix/matrix.jsm
+++ b/chat/protocols/matrix/matrix.jsm
@@ -258,25 +258,36 @@ MatrixAccount.prototype = {
     //  Session.logged_out
     //  User.avatarUrl
     //  User.currentlyActive
     //  User.displayName
     //  User.presence
 
     this._client.startClient();
 
+    this._client.on("Room.name", room => {
+      // Update the title to the human readable version.
+      let conv = this._roomList[room.roomId];
+      if (
+        conv &&
+        room.summary &&
+        room.summary.info &&
+        room.summary.info.title &&
+        conv._name != room.summary.info.title
+      ) {
+        conv._name = room.summary.info.title;
+        conv.notifyObservers(null, "update-conv-title");
+      }
+    });
+
     // Get the list of joined rooms on the server and create those conversations.
     this._client.getJoinedRooms().then(response => {
       for (let roomId of response.joined_rooms) {
         let conv = new MatrixConversation(this, roomId, this.userId);
         this._roomList[roomId] = conv;
-        let room = this._client.getRoom(roomId);
-        if (room) {
-          conv.initRoom(room);
-        }
       }
     });
   },
 
   updateRoomMember(event, member) {
     if (member.roomId in this._roomList) {
       let conv = this._roomList[member.roomId];
       let participant = conv._participants.get(member.userId);