2020-12-04 17:15:18 +01:00
|
|
|
<template>
|
2020-12-09 15:20:50 +01:00
|
|
|
<v-container fluid v-if="room">
|
2020-12-04 17:15:18 +01:00
|
|
|
<v-row class="chat-header-row">
|
|
|
|
|
<v-col
|
|
|
|
|
class="chat-header-members text-center flex-grow-0 flex-shrink-1 ma-0 pa-0"
|
|
|
|
|
>
|
2020-12-09 21:50:53 +01:00
|
|
|
<v-avatar size="40">
|
2020-12-09 15:20:50 +01:00
|
|
|
<v-img :src="room.avatar" />
|
|
|
|
|
</v-avatar>
|
2020-12-04 17:15:18 +01:00
|
|
|
</v-col>
|
|
|
|
|
|
|
|
|
|
<v-col class="flex-grow-1 flex-shrink-1 ma-0 pa-0">
|
2020-12-09 15:20:50 +01:00
|
|
|
<div class="room-name" @click.stop="showRoomInfo">{{ room.summary.info.title }}</div>
|
|
|
|
|
<div class="num-members">{{ memberCount }}{{ memberCount > 1 ? " members" : " member" }}</div>
|
2020-12-04 17:15:18 +01:00
|
|
|
</v-col>
|
|
|
|
|
<v-col class="text-center flex-grow-0 flex-shrink-1 ma-0 pa-0">
|
2020-12-09 15:20:50 +01:00
|
|
|
<v-btn text class="leave-button" @click.stop="leaveRoom">Leave</v-btn>
|
2020-12-04 17:15:18 +01:00
|
|
|
</v-col>
|
|
|
|
|
</v-row>
|
2021-01-11 17:54:12 +01:00
|
|
|
|
|
|
|
|
<!-- "REALLY LEAVE?" dialog -->
|
2021-01-20 14:44:10 +01:00
|
|
|
<LeaveRoomDialog :show="showLeaveConfirmation" :room="room" @close="showLeaveConfirmation = false" />
|
2021-01-11 17:54:12 +01:00
|
|
|
|
2020-12-04 17:15:18 +01:00
|
|
|
</v-container>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-01-20 14:44:10 +01:00
|
|
|
import LeaveRoomDialog from '../components/LeaveRoomDialog';
|
|
|
|
|
|
2020-12-04 17:15:18 +01:00
|
|
|
export default {
|
|
|
|
|
name: "ChatHeader",
|
2021-01-20 14:44:10 +01:00
|
|
|
components: {
|
|
|
|
|
LeaveRoomDialog
|
|
|
|
|
},
|
2020-12-04 17:15:18 +01:00
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
memberCount: null,
|
2021-01-11 17:54:12 +01:00
|
|
|
showLeaveConfirmation: false
|
2020-12-04 17:15:18 +01:00
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
this.$matrix.on("Room.timeline", this.onEvent);
|
|
|
|
|
this.updateMemberCount();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
destroyed() {
|
|
|
|
|
this.$matrix.off("Room.timeline", this.onEvent);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
computed: {
|
|
|
|
|
room() {
|
|
|
|
|
return this.$matrix.currentRoom;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
watch: {
|
|
|
|
|
room: {
|
|
|
|
|
handler(newVal, ignoredOldVal) {
|
2020-12-09 15:20:50 +01:00
|
|
|
if (newVal) {
|
|
|
|
|
this.memberCount = newVal.getJoinedMemberCount();
|
|
|
|
|
} else {
|
|
|
|
|
this.memberCount = null;
|
|
|
|
|
}
|
2020-12-04 17:15:18 +01:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
onEvent(event) {
|
|
|
|
|
if (event.getRoomId() !== this.roomId) {
|
|
|
|
|
return; // Not for this room
|
|
|
|
|
}
|
|
|
|
|
if (event.getType() == "m.room.member") {
|
|
|
|
|
this.updateMemberCount();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
updateMemberCount() {
|
2021-01-11 17:42:58 +01:00
|
|
|
if (!this.room) {
|
|
|
|
|
this.memberCount = 0;
|
|
|
|
|
} else {
|
|
|
|
|
this.memberCount = this.room.getJoinedMemberCount();
|
|
|
|
|
}
|
2020-12-04 17:15:18 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
showRoomInfo() {
|
2021-01-12 11:32:24 +01:00
|
|
|
this.$navigation.push({ name: "RoomInfo" });
|
2020-12-04 17:15:18 +01:00
|
|
|
},
|
2020-12-09 15:20:50 +01:00
|
|
|
|
|
|
|
|
leaveRoom() {
|
2021-01-11 17:54:12 +01:00
|
|
|
this.showLeaveConfirmation = true;
|
|
|
|
|
},
|
2020-12-04 17:15:18 +01:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
@import "@/assets/css/chat.scss";
|
|
|
|
|
</style>
|