From 5bbc5cad9f26df1de735cdffad69e8db973e40eb Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 2 Nov 2020 17:20:03 +0000 Subject: [PATCH] Client setProfile methods update own user --- src/client.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/client.js b/src/client.js index 3f2ac2c66..28f936a1e 100644 --- a/src/client.js +++ b/src/client.js @@ -3702,10 +3702,16 @@ MatrixClient.prototype.setProfileInfo = function(info, data, callback) { * @return {Promise} Resolves: TODO * @return {module:http-api.MatrixError} Rejects: with an error response. */ -MatrixClient.prototype.setDisplayName = function(name, callback) { - return this.setProfileInfo( +MatrixClient.prototype.setDisplayName = async function(name, callback) { + const prom = await this.setProfileInfo( "displayname", { displayname: name }, callback, ); + const user = this.getUser(this.getUserId()); + if (user) { + user.displayName = name; + user.emit("User.displayName"); + } + return prom; }; /** @@ -3714,10 +3720,16 @@ MatrixClient.prototype.setDisplayName = function(name, callback) { * @return {Promise} Resolves: TODO * @return {module:http-api.MatrixError} Rejects: with an error response. */ -MatrixClient.prototype.setAvatarUrl = function(url, callback) { - return this.setProfileInfo( +MatrixClient.prototype.setAvatarUrl = async function(url, callback) { + const prom = await this.setProfileInfo( "avatar_url", { avatar_url: url }, callback, ); + const user = this.getUser(this.getUserId()); + if (user) { + user.avatarUrl = url; + user.emit("User.avatarUrl"); + } + return prom; }; /**