80 lines
1.9 KiB
Vue
80 lines
1.9 KiB
Vue
<template>
|
|
<!-- TODO: move closed style to it's own class -->
|
|
<div
|
|
v-if="isChannelVisible"
|
|
ref="element"
|
|
:class="[
|
|
'channel-list-item',
|
|
{active: activeChannel && channel === activeChannel.channel},
|
|
{'parted-channel': channel.type === 'channel' && channel.state === 0},
|
|
{'has-draft': channel.pendingMessage},
|
|
{
|
|
'not-secure':
|
|
channel.type === 'lobby' && network.status.connected && !network.status.secure,
|
|
},
|
|
{'not-connected': channel.type === 'lobby' && !network.status.connected},
|
|
]"
|
|
:aria-label="getAriaLabel()"
|
|
:title="getAriaLabel()"
|
|
:data-name="channel.name"
|
|
:data-type="channel.type"
|
|
:aria-controls="'#chan-' + channel.id"
|
|
:aria-selected="activeChannel && channel === activeChannel.channel"
|
|
:style="channel.closed ? {transition: 'none', opacity: 0.4} : null"
|
|
role="tab"
|
|
@click="click"
|
|
@contextmenu.prevent="openContextMenu"
|
|
>
|
|
<slot :network="network" :channel="channel" :activeChannel="activeChannel" />
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import isChannelCollapsed from "../js/helpers/isChannelCollapsed";
|
|
|
|
export default {
|
|
name: "ChannelWrapper",
|
|
props: {
|
|
network: Object,
|
|
channel: Object,
|
|
},
|
|
computed: {
|
|
activeChannel() {
|
|
return this.$store.state.activeChannel;
|
|
},
|
|
isChannelVisible() {
|
|
return !isChannelCollapsed(this.network, this.channel);
|
|
},
|
|
},
|
|
methods: {
|
|
getAriaLabel() {
|
|
const extra = [];
|
|
|
|
if (this.channel.unread > 0) {
|
|
extra.push(`${this.channel.unread} unread`);
|
|
}
|
|
|
|
if (this.channel.highlight > 0) {
|
|
extra.push(`${this.channel.highlight} mention`);
|
|
}
|
|
|
|
if (extra.length > 0) {
|
|
return `${this.channel.name} (${extra.join(", ")})`;
|
|
}
|
|
|
|
return this.channel.name;
|
|
},
|
|
click() {
|
|
this.$root.switchToChannel(this.channel);
|
|
},
|
|
openContextMenu(event) {
|
|
this.$root.$emit("contextmenu:channel", {
|
|
event: event,
|
|
channel: this.channel,
|
|
network: this.network,
|
|
});
|
|
},
|
|
},
|
|
};
|
|
</script>
|