mirror of
https://github.com/thelounge/thelounge
synced 2024-11-23 04:23:13 +00:00
85 lines
1.9 KiB
Vue
85 lines
1.9 KiB
Vue
<template>
|
|
<!-- TODO: move closed style to it's own class -->
|
|
<div
|
|
v-if="isChannelVisible"
|
|
ref="element"
|
|
:class="[
|
|
'chan',
|
|
channel.type,
|
|
{active: activeChannel && channel === activeChannel.channel},
|
|
{'parted-channel': channel.type === 'channel' && channel.state === 0},
|
|
]"
|
|
:aria-label="getAriaLabel()"
|
|
:title="getAriaLabel()"
|
|
:data-name="channel.name"
|
|
:aria-controls="'#chan-' + channel.id"
|
|
:aria-selected="activeChannel && channel === activeChannel.channel"
|
|
:style="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 socket from "../js/socket";
|
|
import {generateChannelContextMenu} from "../js/helpers/contextMenu.js";
|
|
import isChannelCollapsed from "../js/helpers/isChannelCollapsed";
|
|
|
|
export default {
|
|
name: "ChannelWrapper",
|
|
props: {
|
|
network: Object,
|
|
channel: Object,
|
|
},
|
|
data() {
|
|
return {
|
|
closed: false,
|
|
};
|
|
},
|
|
computed: {
|
|
activeChannel() {
|
|
return this.$store.state.activeChannel;
|
|
},
|
|
isChannelVisible() {
|
|
return !isChannelCollapsed(this.network, this.channel);
|
|
},
|
|
},
|
|
methods: {
|
|
close() {
|
|
this.closed = true;
|
|
|
|
socket.emit("input", {
|
|
target: Number(this.channel.id),
|
|
text: "/close",
|
|
});
|
|
},
|
|
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) {
|
|
const items = generateChannelContextMenu(this.$root, this.channel, this.network);
|
|
this.$root.$refs.app.openContextMenu(event, items);
|
|
},
|
|
},
|
|
};
|
|
</script>
|