2018-07-12 19:24:35 +00:00
|
|
|
<template>
|
2019-11-26 20:50:40 +00:00
|
|
|
<ChannelWrapper v-bind="$props" :channel="channel">
|
2018-07-12 19:24:35 +00:00
|
|
|
<button
|
|
|
|
v-if="network.channels.length > 1"
|
|
|
|
:aria-controls="'network-' + network.uuid"
|
|
|
|
:aria-label="getExpandLabel(network)"
|
|
|
|
:aria-expanded="!network.isCollapsed"
|
|
|
|
class="collapse-network"
|
2019-02-25 05:38:13 +00:00
|
|
|
@click.stop="onCollapseClick"
|
2019-07-17 09:33:59 +00:00
|
|
|
>
|
|
|
|
<span class="collapse-network-icon" />
|
|
|
|
</button>
|
|
|
|
<span v-else class="collapse-network" />
|
2018-07-12 19:24:35 +00:00
|
|
|
<div class="lobby-wrap">
|
2019-07-17 09:33:59 +00:00
|
|
|
<span :title="channel.name" class="name">{{ channel.name }}</span>
|
2018-07-12 19:24:35 +00:00
|
|
|
<span
|
2019-02-27 07:25:44 +00:00
|
|
|
v-if="network.status.connected && !network.status.secure"
|
2018-07-12 19:24:35 +00:00
|
|
|
class="not-secure-tooltip tooltipped tooltipped-w"
|
2019-02-25 05:38:13 +00:00
|
|
|
aria-label="Insecure connection"
|
|
|
|
>
|
2018-07-29 17:57:14 +00:00
|
|
|
<span class="not-secure-icon" />
|
2018-07-12 19:24:35 +00:00
|
|
|
</span>
|
|
|
|
<span
|
2019-02-27 07:25:44 +00:00
|
|
|
v-if="!network.status.connected"
|
2018-07-12 19:24:35 +00:00
|
|
|
class="not-connected-tooltip tooltipped tooltipped-w"
|
2019-02-25 05:38:13 +00:00
|
|
|
aria-label="Disconnected"
|
|
|
|
>
|
2018-07-29 17:57:14 +00:00
|
|
|
<span class="not-connected-icon" />
|
2018-07-12 19:24:35 +00:00
|
|
|
</span>
|
2019-07-17 09:33:59 +00:00
|
|
|
<span v-if="channel.unread" :class="{highlight: channel.highlight}" class="badge">{{
|
2019-11-05 10:36:44 +00:00
|
|
|
unreadCount
|
2019-07-17 09:33:59 +00:00
|
|
|
}}</span>
|
2018-07-12 19:24:35 +00:00
|
|
|
</div>
|
|
|
|
<span
|
|
|
|
:aria-label="joinChannelLabel"
|
2019-02-25 05:38:13 +00:00
|
|
|
class="add-channel-tooltip tooltipped tooltipped-w tooltipped-no-touch"
|
|
|
|
>
|
2018-07-12 19:24:35 +00:00
|
|
|
<button
|
2019-07-17 09:33:59 +00:00
|
|
|
:class="['add-channel', {opened: isJoinChannelShown}]"
|
2018-07-12 19:24:35 +00:00
|
|
|
:aria-controls="'join-channel-' + channel.id"
|
|
|
|
:aria-label="joinChannelLabel"
|
2020-09-30 14:44:07 +00:00
|
|
|
@click.stop="$emit('toggle-join-channel')"
|
2019-02-25 05:38:13 +00:00
|
|
|
/>
|
2018-07-12 19:24:35 +00:00
|
|
|
</span>
|
|
|
|
</ChannelWrapper>
|
|
|
|
</template>
|
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
<script lang="ts">
|
|
|
|
import {computed, defineComponent, PropType} from "vue";
|
2020-01-02 20:41:52 +00:00
|
|
|
import collapseNetwork from "../js/helpers/collapseNetwork";
|
2019-11-16 17:24:03 +00:00
|
|
|
import roundBadgeNumber from "../js/helpers/roundBadgeNumber";
|
2018-07-12 19:24:35 +00:00
|
|
|
import ChannelWrapper from "./ChannelWrapper.vue";
|
|
|
|
|
2022-06-19 00:25:21 +00:00
|
|
|
import type {ClientChan, ClientNetwork} from "../js/types";
|
|
|
|
|
|
|
|
export default defineComponent({
|
2018-07-12 19:24:35 +00:00
|
|
|
name: "Channel",
|
|
|
|
components: {
|
|
|
|
ChannelWrapper,
|
|
|
|
},
|
|
|
|
props: {
|
2022-06-19 00:25:21 +00:00
|
|
|
network: {
|
|
|
|
type: Object as PropType<ClientNetwork>,
|
|
|
|
required: true,
|
|
|
|
},
|
2018-07-12 19:24:35 +00:00
|
|
|
isJoinChannelShown: Boolean,
|
2019-11-26 20:50:40 +00:00
|
|
|
active: Boolean,
|
|
|
|
isFiltering: Boolean,
|
2018-07-12 19:24:35 +00:00
|
|
|
},
|
2022-06-19 00:25:21 +00:00
|
|
|
emits: ["toggle-join-channel"],
|
|
|
|
setup(props) {
|
|
|
|
const channel = computed(() => {
|
|
|
|
return props.network.channels[0];
|
|
|
|
});
|
|
|
|
|
|
|
|
const joinChannelLabel = computed(() => {
|
|
|
|
return props.isJoinChannelShown ? "Cancel" : "Join a channel…";
|
|
|
|
});
|
|
|
|
|
|
|
|
const unreadCount = computed(() => {
|
|
|
|
return roundBadgeNumber(channel.value.unread);
|
|
|
|
});
|
|
|
|
|
|
|
|
const onCollapseClick = () => {
|
|
|
|
collapseNetwork(props.network, !props.network.isCollapsed);
|
|
|
|
};
|
|
|
|
|
|
|
|
const getExpandLabel = (network: ClientNetwork) => {
|
2018-07-12 19:24:35 +00:00
|
|
|
return network.isCollapsed ? "Expand" : "Collapse";
|
2022-06-19 00:25:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
|
|
channel,
|
|
|
|
joinChannelLabel,
|
|
|
|
unreadCount,
|
|
|
|
onCollapseClick,
|
|
|
|
getExpandLabel,
|
|
|
|
};
|
2018-07-12 19:24:35 +00:00
|
|
|
},
|
2022-06-19 00:25:21 +00:00
|
|
|
});
|
2018-07-12 19:24:35 +00:00
|
|
|
</script>
|