You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Merge pull request #1534 from matrix-org/t3chguy/fix/15604
Client set profile methods update own user
This commit is contained in:
@@ -3699,25 +3699,39 @@ MatrixClient.prototype.setProfileInfo = function(info, data, callback) {
|
|||||||
/**
|
/**
|
||||||
* @param {string} name
|
* @param {string} name
|
||||||
* @param {module:client.callback} callback Optional.
|
* @param {module:client.callback} callback Optional.
|
||||||
* @return {Promise} Resolves: TODO
|
* @return {Promise} Resolves: {} an empty object.
|
||||||
* @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,
|
||||||
);
|
);
|
||||||
|
// XXX: synthesise a profile update for ourselves because Synapse is broken and won't
|
||||||
|
const user = this.getUser(this.getUserId());
|
||||||
|
if (user) {
|
||||||
|
user.displayName = name;
|
||||||
|
user.emit("User.displayName", user.events.presence, user);
|
||||||
|
}
|
||||||
|
return prom;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} url
|
* @param {string} url
|
||||||
* @param {module:client.callback} callback Optional.
|
* @param {module:client.callback} callback Optional.
|
||||||
* @return {Promise} Resolves: TODO
|
* @return {Promise} Resolves: {} an empty object.
|
||||||
* @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,
|
||||||
);
|
);
|
||||||
|
// XXX: synthesise a profile update for ourselves because Synapse is broken and won't
|
||||||
|
const user = this.getUser(this.getUserId());
|
||||||
|
if (user) {
|
||||||
|
user.avatarUrl = url;
|
||||||
|
user.emit("User.avatarUrl", user.events.presence, user);
|
||||||
|
}
|
||||||
|
return prom;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user