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">
|
2021-02-01 22:10:48 +01:00
|
|
|
<div class="room-name" @click.stop="showRoomList = true">{{ room.summary.info.title }} <v-icon>expand_more</v-icon></div>
|
|
|
|
|
<RoomList v-if="showRoomList" v-click-outside="hideRoomList" @close="hideRoomList" />
|
2020-12-09 15:20:50 +01:00
|
|
|
<div class="num-members">{{ memberCount }}{{ memberCount > 1 ? " members" : " member" }}</div>
|
2020-12-04 17:15:18 +01:00
|
|
|
</v-col>
|
2021-02-01 22:10:48 +01:00
|
|
|
<v-col class="text-center flex-grow-0 flex-shrink-1 ma-0 pa-0">
|
|
|
|
|
<v-btn text class="info-button" @click.stop="showRoomInfo"><v-icon color="black">info</v-icon></v-btn>
|
|
|
|
|
</v-col>
|
2020-12-04 17:15:18 +01:00
|
|
|
<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';
|
2021-02-01 22:10:48 +01:00
|
|
|
import RoomList from "../components/RoomList";
|
2021-01-20 14:44:10 +01:00
|
|
|
|
2020-12-04 17:15:18 +01:00
|
|
|
export default {
|
|
|
|
|
name: "ChatHeader",
|
2021-01-20 14:44:10 +01:00
|
|
|
components: {
|
2021-02-01 22:10:48 +01:00
|
|
|
LeaveRoomDialog,
|
|
|
|
|
RoomList
|
2021-01-20 14:44:10 +01:00
|
|
|
},
|
2020-12-04 17:15:18 +01:00
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
memberCount: null,
|
2021-02-01 22:10:48 +01:00
|
|
|
showRoomList: false,
|
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;
|
|
|
|
|
},
|
2021-02-01 22:10:48 +01:00
|
|
|
|
|
|
|
|
hideRoomList() {
|
|
|
|
|
this.showRoomList = false;
|
|
|
|
|
}
|
2020-12-04 17:15:18 +01:00
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
|
@import "@/assets/css/chat.scss";
|
|
|
|
|
</style>
|