2020-12-04 17:15:18 +01:00
|
|
|
<template>
|
2020-12-09 15:20:50 +01:00
|
|
|
<v-container fluid v-if="room">
|
2021-02-09 11:10:17 +01:00
|
|
|
<v-row class="chat-header-row flex-nowrap">
|
2020-12-04 17:15:18 +01:00
|
|
|
<v-col
|
2021-06-29 11:55:53 +02:00
|
|
|
cols="auto"
|
2021-02-09 11:10:17 +01:00
|
|
|
class="chat-header-members text-start ma-0 pa-0"
|
2021-06-29 11:55:53 +02:00
|
|
|
@click.stop="onHeaderClicked"
|
2020-12-04 17:15:18 +01:00
|
|
|
>
|
2021-06-29 11:55:53 +02:00
|
|
|
<v-avatar size="40" class="me-2">
|
2022-05-17 15:16:53 +00:00
|
|
|
<v-img v-if="room.avatar || memberAvatar" :src="room.avatar || memberAvatar" />
|
2020-12-09 15:20:50 +01:00
|
|
|
</v-avatar>
|
2020-12-04 17:15:18 +01:00
|
|
|
</v-col>
|
|
|
|
|
|
2021-06-29 11:55:53 +02:00
|
|
|
<v-col
|
2022-02-23 11:52:09 +00:00
|
|
|
class="chat-header-name ma-0 pa-0 flex-shrink-1 flex-nowrap"
|
2021-06-29 11:55:53 +02:00
|
|
|
@click.stop="onHeaderClicked"
|
|
|
|
|
>
|
2021-11-23 12:21:22 +00:00
|
|
|
<div class="room-name-inline text-truncate" :title="room.name">
|
2023-02-28 10:29:53 +00:00
|
|
|
{{ room.name }}<v-icon class="icon-dropdown" size="11">$vuetify.icons.ic_dropdown</v-icon><div class="notification-alert" v-if="notifications"></div>
|
|
|
|
|
|
2021-06-29 11:55:53 +02:00
|
|
|
<!--<v-icon>expand_more</v-icon>-->
|
|
|
|
|
</div>
|
|
|
|
|
<div class="num-members">{{ $tc("room.members", memberCount) }}</div>
|
2020-12-04 17:15:18 +01:00
|
|
|
</v-col>
|
2021-02-09 11:10:17 +01:00
|
|
|
<v-col cols="auto" class="text-end ma-0 pa-0">
|
2022-04-25 08:44:25 +00:00
|
|
|
<v-btn
|
|
|
|
|
id="btn-purge-room"
|
|
|
|
|
v-if="userCanPurgeRoom"
|
2023-02-13 14:25:37 +02:00
|
|
|
class="mx-2 box-shadow-none"
|
|
|
|
|
fab
|
|
|
|
|
dark
|
|
|
|
|
small
|
2022-04-25 08:44:25 +00:00
|
|
|
color="red"
|
|
|
|
|
@click.stop="showPurgeConfirmation = true"
|
|
|
|
|
>
|
2023-02-13 14:25:37 +02:00
|
|
|
<v-icon light>$vuetify.icons.ic_moderator-delete</v-icon>
|
2022-04-25 08:44:25 +00:00
|
|
|
</v-btn>
|
|
|
|
|
<v-btn
|
|
|
|
|
id="btn-leave-room"
|
2023-02-13 14:25:37 +02:00
|
|
|
class="mx-2 box-shadow-none"
|
|
|
|
|
fab
|
|
|
|
|
dark
|
|
|
|
|
small
|
|
|
|
|
color="red"
|
2022-04-25 08:44:25 +00:00
|
|
|
@click.stop="leaveRoom"
|
|
|
|
|
v-else
|
|
|
|
|
>
|
2023-02-13 14:25:37 +02:00
|
|
|
<v-icon>$vuetify.icons.ic_member-leave</v-icon>
|
2022-04-25 08:44:25 +00:00
|
|
|
</v-btn>
|
2020-12-04 17:15:18 +01:00
|
|
|
</v-col>
|
2021-06-29 11:55:53 +02:00
|
|
|
<v-col cols="auto" class="text-end ma-0 pa-0 ms-2">
|
|
|
|
|
<v-avatar
|
|
|
|
|
class="avatar-32 clickable"
|
2023-02-13 14:25:37 +02:00
|
|
|
size="40"
|
2021-06-29 11:55:53 +02:00
|
|
|
color="#e0e0e0"
|
|
|
|
|
@click.stop="showProfileInfo = true"
|
|
|
|
|
>
|
2021-06-17 20:56:25 +02:00
|
|
|
<img v-if="userAvatar" :src="userAvatar" />
|
2021-06-29 11:55:53 +02:00
|
|
|
<span v-else class="white--text">{{ userAvatarLetter }}</span>
|
|
|
|
|
</v-avatar>
|
2021-06-17 20:56:25 +02:00
|
|
|
</v-col>
|
2020-12-04 17:15:18 +01:00
|
|
|
</v-row>
|
2021-01-11 17:54:12 +01:00
|
|
|
|
|
|
|
|
<!-- "REALLY LEAVE?" dialog -->
|
2021-06-29 11:55:53 +02:00
|
|
|
<LeaveRoomDialog
|
|
|
|
|
:show="showLeaveConfirmation"
|
|
|
|
|
:room="room"
|
|
|
|
|
@close="showLeaveConfirmation = false"
|
|
|
|
|
/>
|
2021-01-11 17:54:12 +01:00
|
|
|
|
2021-06-17 20:56:25 +02:00
|
|
|
<!-- PROFILE INFO POPUP -->
|
2021-06-29 11:55:53 +02:00
|
|
|
<ProfileInfoPopup
|
|
|
|
|
:show="showProfileInfo"
|
|
|
|
|
@close="showProfileInfo = false"
|
|
|
|
|
/>
|
2022-04-25 08:44:25 +00:00
|
|
|
<!-- PURGE ROOM POPUP -->
|
|
|
|
|
<PurgeRoomDialog
|
|
|
|
|
:show="showPurgeConfirmation"
|
|
|
|
|
:room="room"
|
|
|
|
|
@close="showPurgeConfirmation = false"
|
|
|
|
|
/>
|
2020-12-04 17:15:18 +01:00
|
|
|
</v-container>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-06-29 11:55:53 +02:00
|
|
|
import LeaveRoomDialog from "../components/LeaveRoomDialog";
|
|
|
|
|
import ProfileInfoPopup from "../components/ProfileInfoPopup";
|
|
|
|
|
import profileInfoMixin from "../components/profileInfoMixin";
|
2022-04-25 08:44:25 +00:00
|
|
|
import PurgeRoomDialog from "../components/PurgeRoomDialog";
|
|
|
|
|
|
|
|
|
|
import roomInfoMixin from "./roomInfoMixin";
|
2021-01-20 14:44:10 +01:00
|
|
|
|
2020-12-04 17:15:18 +01:00
|
|
|
export default {
|
|
|
|
|
name: "ChatHeader",
|
2022-04-25 08:44:25 +00:00
|
|
|
mixins: [profileInfoMixin, roomInfoMixin],
|
2021-01-20 14:44:10 +01:00
|
|
|
components: {
|
2021-06-17 20:56:25 +02:00
|
|
|
LeaveRoomDialog,
|
2021-06-29 11:55:53 +02:00
|
|
|
ProfileInfoPopup,
|
2022-04-25 08:44:25 +00:00
|
|
|
PurgeRoomDialog
|
2021-01-20 14:44:10 +01:00
|
|
|
},
|
2020-12-04 17:15:18 +01:00
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
memberCount: null,
|
2021-06-17 20:56:25 +02:00
|
|
|
showLeaveConfirmation: false,
|
2021-06-29 11:55:53 +02:00
|
|
|
showProfileInfo: false,
|
2022-04-25 08:44:25 +00:00
|
|
|
showPurgeConfirmation: 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;
|
|
|
|
|
},
|
2022-01-27 11:35:20 +00:00
|
|
|
memberAvatar() {
|
|
|
|
|
let roomMember;
|
|
|
|
|
if (this.room) {
|
|
|
|
|
this.room.getMembers().forEach(member => {
|
|
|
|
|
if(this.room.name === member.name) {
|
|
|
|
|
roomMember = member;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
if (roomMember) {
|
|
|
|
|
return roomMember.getAvatarUrl(
|
|
|
|
|
this.$matrix.matrixClient.getHomeserverUrl(),
|
|
|
|
|
40,
|
|
|
|
|
40,
|
|
|
|
|
"scale",
|
|
|
|
|
true
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
2023-02-28 10:29:53 +00:00
|
|
|
},
|
|
|
|
|
notifications() {
|
|
|
|
|
return this.$matrix.joinedRooms.some(room => room.roomId !== this.$matrix.currentRoomId && room.getUnreadNotificationCount("total") > 0);
|
2022-01-27 11:35:20 +00:00
|
|
|
}
|
2020-12-04 17:15:18 +01:00
|
|
|
},
|
|
|
|
|
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) {
|
2021-09-14 13:07:15 +02:00
|
|
|
if (!this.room || event.getRoomId() !== this.room.roomId) {
|
2020-12-04 17:15:18 +01:00
|
|
|
return; // Not for this room
|
|
|
|
|
}
|
|
|
|
|
if (event.getType() == "m.room.member") {
|
|
|
|
|
this.updateMemberCount();
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-06-29 11:55:53 +02:00
|
|
|
|
2021-03-11 13:55:10 +01:00
|
|
|
onHeaderClicked() {
|
2021-06-29 11:55:53 +02:00
|
|
|
this.$emit("header-click", { event: this.event });
|
2021-03-11 13:55:10 +01:00
|
|
|
},
|
2020-12-04 17:15:18 +01:00
|
|
|
|
|
|
|
|
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
|
|
|
},
|
|
|
|
|
|
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>
|