Set avatar and displayname on join
Also on the main matrix object.
This commit is contained in:
parent
ae2c8d8e2e
commit
2fb883a4d1
2 changed files with 13 additions and 6 deletions
|
|
@ -327,9 +327,14 @@ export default {
|
|||
// Set avatar and display name to either the randomly chosen ones, or the
|
||||
// ones the users has changed to.
|
||||
setProfileData = true;
|
||||
|
||||
// Set display name and avatar directly on the matrix object.
|
||||
if (this.selectedProfile.name && this.selectedProfile.name.length > 0) {
|
||||
this.$matrix.userDisplayName = this.selectedProfile.name;
|
||||
}
|
||||
}
|
||||
|
||||
if (!setProfileData || !this.selectedProfile.name) {
|
||||
if (!setProfileData || !this.selectedProfile.name || this.selectedProfile.name.length == 0) {
|
||||
return Promise.resolve(user);
|
||||
} else {
|
||||
console.log("Join: Set display name to: " + this.selectedProfile.name);
|
||||
|
|
@ -348,7 +353,7 @@ export default {
|
|||
} else {
|
||||
console.log("Join: Updating avatar");
|
||||
return util.setAvatar(
|
||||
this.$matrix.matrixClient,
|
||||
this.$matrix,
|
||||
this.selectedProfile.image,
|
||||
function (progress) {
|
||||
console.log("Progress: " + JSON.stringify(progress));
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ class Util {
|
|||
return this._importAll(require.context('../assets/avatars/', true, /\.(jpeg|jpg|png)$/));
|
||||
}
|
||||
|
||||
setAvatar(matrixClient, file, onUploadProgress) {
|
||||
setAvatar(matrix, file, onUploadProgress) {
|
||||
return new Promise((resolve, reject) => {
|
||||
axios.get(file, { responseType: 'arraybuffer' })
|
||||
.then(response => {
|
||||
|
|
@ -471,12 +471,14 @@ class Util {
|
|||
progressHandler: onUploadProgress,
|
||||
onlyContentUri: false
|
||||
};
|
||||
matrixClient.uploadContent(response.data, opts)
|
||||
var avatarUri;
|
||||
matrix.matrixClient.uploadContent(response.data, opts)
|
||||
.then((response) => {
|
||||
const uri = response.content_uri;
|
||||
return matrixClient.setAvatarUrl(uri);
|
||||
avatarUri = response.content_uri;
|
||||
return matrix.matrixClient.setAvatarUrl(avatarUri);
|
||||
})
|
||||
.then(result => {
|
||||
matrix.userAvatar = avatarUri;
|
||||
resolve(result);
|
||||
})
|
||||
.catch(err => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue