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