1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Client setProfile methods update own user

This commit is contained in:
Michael Telatynski
2020-11-02 17:20:03 +00:00
parent 7f130949c8
commit 5bbc5cad9f

View File

@@ -3702,10 +3702,16 @@ MatrixClient.prototype.setProfileInfo = function(info, data, callback) {
* @return {Promise} Resolves: TODO * @return {Promise} Resolves: TODO
* @return {module:http-api.MatrixError} Rejects: with an error response. * @return {module:http-api.MatrixError} Rejects: with an error response.
*/ */
MatrixClient.prototype.setDisplayName = function(name, callback) { MatrixClient.prototype.setDisplayName = async function(name, callback) {
return this.setProfileInfo( const prom = await this.setProfileInfo(
"displayname", { displayname: name }, callback, "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 {Promise} Resolves: TODO
* @return {module:http-api.MatrixError} Rejects: with an error response. * @return {module:http-api.MatrixError} Rejects: with an error response.
*/ */
MatrixClient.prototype.setAvatarUrl = function(url, callback) { MatrixClient.prototype.setAvatarUrl = async function(url, callback) {
return this.setProfileInfo( const prom = await this.setProfileInfo(
"avatar_url", { avatar_url: url }, callback, "avatar_url", { avatar_url: url }, callback,
); );
const user = this.getUser(this.getUserId());
if (user) {
user.avatarUrl = url;
user.emit("User.avatarUrl");
}
return prom;
}; };
/** /**