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> <div class="you-are">{{ $t("profile_info_popup.you_are") }}</div>
<v-container fluid> <v-container fluid>
<v-row> <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"> <div v-if="$matrix.currentUser.is_guest">
<i18n path="profile_info_popup.identity_temporary" tag="span"> <i18n path="profile_info_popup.identity_temporary" tag="span">
<template v-slot:displayName> <template v-slot:displayName>
<b>{{ displayName }}</b> <input
v-model="displayName"
@blur="
setDisplayName($event.target.value);
editDisplayName = !editDisplayName;
"
@focus="editDisplayName = !editDisplayName"
/>
</template> </template>
</i18n> </i18n>
</div> </div>
@ -96,6 +103,7 @@ export default {
data() { data() {
return { return {
showDialog: false, showDialog: false,
editDisplayName: false
}; };
}, },
computed: { computed: {
@ -168,6 +176,19 @@ export default {
.username { .username {
border-radius: 4px; border-radius: 4px;
background-color: #f5f5f5; 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 { .more-container {
border-radius: 10px; border-radius: 10px;

View file

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