2018-07-12 19:24:35 +00:00
|
|
|
<template>
|
2019-04-13 20:44:04 +00:00
|
|
|
<!-- TODO: move closed style to it's own class -->
|
2018-07-12 19:24:35 +00:00
|
|
|
<div
|
2019-11-20 20:54:00 +00:00
|
|
|
v-if="isChannelVisible"
|
2019-08-03 19:03:45 +00:00
|
|
|
ref="element"
|
2019-02-07 07:24:53 +00:00
|
|
|
:class="[
|
2019-12-04 06:58:23 +00:00
|
|
|
'channel-list-item',
|
2019-11-26 20:50:40 +00:00
|
|
|
{active: active},
|
2019-07-17 09:33:59 +00:00
|
|
|
{'parted-channel': channel.type === 'channel' && channel.state === 0},
|
2019-11-26 22:27:11 +00:00
|
|
|
{'has-draft': channel.pendingMessage},
|
2019-12-19 13:22:04 +00:00
|
|
|
{
|
|
|
|
'not-secure':
|
|
|
|
channel.type === 'lobby' && network.status.connected && !network.status.secure,
|
|
|
|
},
|
|
|
|
{'not-connected': channel.type === 'lobby' && !network.status.connected},
|
2019-02-07 07:24:53 +00:00
|
|
|
]"
|
2018-10-05 09:14:30 +00:00
|
|
|
:aria-label="getAriaLabel()"
|
|
|
|
:title="getAriaLabel()"
|
2019-01-02 12:09:50 +00:00
|
|
|
:data-name="channel.name"
|
2019-12-04 06:58:23 +00:00
|
|
|
:data-type="channel.type"
|
2018-07-12 19:24:35 +00:00
|
|
|
:aria-controls="'#chan-' + channel.id"
|
2019-11-26 20:50:40 +00:00
|
|
|
:aria-selected="active"
|
2019-11-23 16:44:23 +00:00
|
|
|
:style="channel.closed ? {transition: 'none', opacity: 0.4} : null"
|
2019-02-25 05:38:13 +00:00
|
|
|
role="tab"
|
2019-10-17 16:56:44 +00:00
|
|
|
@click="click"
|
2019-11-09 22:21:34 +00:00
|
|
|
@contextmenu.prevent="openContextMenu"
|
2019-02-25 05:38:13 +00:00
|
|
|
>
|
2019-07-17 09:33:59 +00:00
|
|
|
<slot :network="network" :channel="channel" :activeChannel="activeChannel" />
|
2018-07-12 19:24:35 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-11-20 20:54:00 +00:00
|
|
|
import isChannelCollapsed from "../js/helpers/isChannelCollapsed";
|
2019-03-03 19:43:57 +00:00
|
|
|
|
2018-07-12 19:24:35 +00:00
|
|
|
export default {
|
|
|
|
name: "ChannelWrapper",
|
|
|
|
props: {
|
|
|
|
network: Object,
|
|
|
|
channel: Object,
|
2019-11-26 20:50:40 +00:00
|
|
|
active: Boolean,
|
|
|
|
isFiltering: Boolean,
|
2018-07-12 19:24:35 +00:00
|
|
|
},
|
2019-11-02 19:40:59 +00:00
|
|
|
computed: {
|
|
|
|
activeChannel() {
|
|
|
|
return this.$store.state.activeChannel;
|
|
|
|
},
|
2019-11-20 20:54:00 +00:00
|
|
|
isChannelVisible() {
|
2019-11-26 20:50:40 +00:00
|
|
|
return this.isFiltering || !isChannelCollapsed(this.network, this.channel);
|
2019-11-20 20:54:00 +00:00
|
|
|
},
|
2019-11-02 19:40:59 +00:00
|
|
|
},
|
2018-10-05 09:14:30 +00:00
|
|
|
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;
|
|
|
|
},
|
2019-10-17 16:56:44 +00:00
|
|
|
click() {
|
2020-02-10 15:43:39 +00:00
|
|
|
if (this.isFiltering) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-10-25 21:37:40 +00:00
|
|
|
this.$root.switchToChannel(this.channel);
|
2019-10-17 16:56:44 +00:00
|
|
|
},
|
2019-11-09 22:21:34 +00:00
|
|
|
openContextMenu(event) {
|
2019-11-23 14:26:20 +00:00
|
|
|
this.$root.$emit("contextmenu:channel", {
|
|
|
|
event: event,
|
|
|
|
channel: this.channel,
|
|
|
|
network: this.network,
|
|
|
|
});
|
2019-11-09 22:21:34 +00:00
|
|
|
},
|
2018-10-05 09:14:30 +00:00
|
|
|
},
|
2018-07-12 19:24:35 +00:00
|
|
|
};
|
|
|
|
</script>
|