Change identity from profile popup

This commit is contained in:
10G Meow 2022-02-20 11:38:22 +02:00
parent 128b19ef8f
commit ab749cd932
2 changed files with 35 additions and 6 deletions

View file

@ -9,11 +9,18 @@
<div class="you-are">{{ $t("profile_info_popup.you_are") }}</div>
<v-container fluid>
<v-row>
<v-col class="username" cols="pa-2">
<v-col :class="['username',{'editable': editDisplayName }]" cols="pa-2" ref="username">
<div v-if="$matrix.currentUser.is_guest">
<i18n path="profile_info_popup.identity_temporary" tag="span">
<template v-slot:displayName>
<b>{{ displayName }}</b>
<input
v-model="displayName"
@blur="
setDisplayName($event.target.value);
editDisplayName = !editDisplayName;
"
@focus="editDisplayName = !editDisplayName"
/>
</template>
</i18n>
</div>
@ -96,6 +103,7 @@ export default {
data() {
return {
showDialog: false,
editDisplayName: false
};
},
computed: {
@ -168,6 +176,19 @@ export default {
.username {
border-radius: 4px;
background-color: #f5f5f5;
&.editable {
background-color: unset;
box-shadow: 0px 2px 6px rgb(0 0 0 / 8%);
}
input {
width: 100%;
&:focus {
outline: none;
}
}
}
.more-container {
border-radius: 10px;

View file

@ -7,11 +7,16 @@ export default {
return this.$matrix.matrixClient.getUser(this.$matrix.currentUserId);
},
displayName() {
if (!this.user) {
return null;
displayName: {
get() {
if (!this.user) {
return null;
}
return (this.user.displayName || this.user.userId);
},
set(newValue) {
this.user.displayName = newValue
}
return (this.user.displayName || this.user.userId);
},
userAvatar() {
@ -40,5 +45,8 @@ export default {
this.$navigation.push({path: "/login"}, -1);
})
},
setDisplayName(name) {
this.$matrix.matrixClient.setDisplayName(name);
}
}
}