Cleanup code in Profile view

This commit is contained in:
N-Pex 2021-03-01 13:06:21 +01:00
parent a892ee780f
commit 3b3e21b8da

View file

@ -1,5 +1,5 @@
<template> <template>
<div v-if="room" class="profile"> <div v-if="user" class="profile">
<div class="chat-header"> <div class="chat-header">
<v-container fluid> <v-container fluid>
<div class="room-name">My Profile</div> <div class="room-name">My Profile</div>
@ -91,30 +91,20 @@
<script> <script>
export default { export default {
name: "RoomInfo", name: "Profile",
data() { data() {
return { return {
memberCount: null,
showEditPasswordDialog: false, showEditPasswordDialog: false,
showEditDisplaynameDialog: false, showEditDisplaynameDialog: false,
editValue: null, editValue: null,
}; };
}, },
mounted() {
this.$matrix.on("Room.timeline", this.onEvent);
this.updateMemberCount();
},
destroyed() {
this.$matrix.off("Room.timeline", this.onEvent);
},
computed: { computed: {
room() {
return this.$matrix.currentRoom;
},
user() { user() {
if (!this.$matrix.matrixClient) {
return null;
}
return this.$matrix.matrixClient.getUser(this.$matrix.currentUserId); return this.$matrix.matrixClient.getUser(this.$matrix.currentUserId);
}, },
@ -140,44 +130,7 @@ export default {
} }
}, },
watch: {
room: {
handler(newVal, ignoredOldVal) {
console.log("RoomInfo: Current room changed");
this.memberCount = newVal.getJoinedMemberCount();
},
},
},
methods: { methods: {
onEvent(event) {
if (event.getRoomId() !== this.roomId) {
return; // Not for this room
}
if (event.getType() == "m.room.member") {
this.updateMemberCount();
}
},
updateMemberCount() {
this.memberCount = this.room.getJoinedMemberCount();
},
showRoomInfo() {},
memberAvatar(member) {
if (member) {
return member.getAvatarUrl(
this.$matrix.matrixClient.getHomeserverUrl(),
40,
40,
"scale",
true
);
}
return null;
},
logout() { logout() {
//TODO - For guest accounts, show warning about not being able to rejoin. //TODO - For guest accounts, show warning about not being able to rejoin.
this.$store.dispatch("auth/logout"); this.$store.dispatch("auth/logout");