thelounge/client/components/Channel.vue
2022-05-01 00:37:21 -07:00

74 lines
1.6 KiB
Vue

<template>
<ChannelWrapper ref="wrapper" v-bind="$props">
<span class="name">{{ name() }}</span>
<span
v-if="channel.unread"
:class="{highlight: channel.highlight && !channel.muted}"
class="badge"
>{{ unreadCount }}</span
>
<template v-if="channel.type === 'channel'">
<span
v-if="channel.state === 0"
class="parted-channel-tooltip tooltipped tooltipped-w"
aria-label="Not currently joined"
>
<span class="parted-channel-icon" />
</span>
<span
class="close-tooltip tooltipped tooltipped-w"
:aria-label="channel.favorite ? 'Unfavorite' : 'Leave'"
>
<button
class="close"
:aria-label="channel.favorite ? 'Unfavorite' : 'Leave'"
@click.stop="close"
/>
</span>
</template>
<template v-else>
<span
class="close-tooltip tooltipped tooltipped-w"
:aria-label="channel.favorite ? 'Unfavorite' : 'Close'"
>
<button
class="close"
:aria-label="channel.favorite ? 'Unfavorite' : 'Close'"
@click.stop="close"
/>
</span>
</template>
</ChannelWrapper>
</template>
<script>
import roundBadgeNumber from "../js/helpers/roundBadgeNumber";
import ChannelWrapper from "./ChannelWrapper.vue";
export default {
name: "Channel",
components: {
ChannelWrapper,
},
props: {
network: Object,
channel: Object,
active: Boolean,
isFiltering: Boolean,
},
computed: {
unreadCount() {
return roundBadgeNumber(this.channel.unread);
},
},
methods: {
close() {
this.$root.closeChannel(this.channel);
},
name() {
return this.channel.displayName ? this.channel.displayName : this.channel.name;
},
},
};
</script>