2018-07-12 19:24:35 +00:00
|
|
|
<template>
|
2019-11-02 19:40:59 +00:00
|
|
|
<ChannelWrapper :network="network" :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">{{
|
|
|
|
channel.unread | roundBadgeNumber
|
|
|
|
}}</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"
|
2019-02-25 05:38:13 +00:00
|
|
|
@click.stop="$emit('toggleJoinChannel')"
|
|
|
|
/>
|
2018-07-12 19:24:35 +00:00
|
|
|
</span>
|
2019-11-02 19:06:34 +00:00
|
|
|
<button class="close" hidden @click="close" />
|
2018-07-12 19:24:35 +00:00
|
|
|
</ChannelWrapper>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import ChannelWrapper from "./ChannelWrapper.vue";
|
2019-11-02 19:06:34 +00:00
|
|
|
import socket from "../js/socket";
|
2018-07-12 19:24:35 +00:00
|
|
|
const storage = require("../js/localStorage");
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "Channel",
|
|
|
|
components: {
|
|
|
|
ChannelWrapper,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
network: Object,
|
|
|
|
isJoinChannelShown: Boolean,
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
channel() {
|
|
|
|
return this.network.channels[0];
|
|
|
|
},
|
|
|
|
joinChannelLabel() {
|
|
|
|
return this.isJoinChannelShown ? "Cancel" : "Join a channel…";
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
2019-11-02 19:06:34 +00:00
|
|
|
close() {
|
|
|
|
// eslint-disable-next-line no-alert
|
|
|
|
if (!confirm(`Are you sure you want to remove ${this.channel.name}?`)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
socket.emit("input", {
|
|
|
|
target: Number(this.channel.id),
|
|
|
|
text: "/quit",
|
|
|
|
});
|
|
|
|
},
|
2018-07-12 19:24:35 +00:00
|
|
|
onCollapseClick() {
|
|
|
|
const networks = new Set(JSON.parse(storage.get("thelounge.networks.collapsed")));
|
|
|
|
this.network.isCollapsed = !this.network.isCollapsed;
|
|
|
|
|
|
|
|
if (this.network.isCollapsed) {
|
|
|
|
networks.add(this.network.uuid);
|
|
|
|
} else {
|
|
|
|
networks.delete(this.network.uuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
storage.set("thelounge.networks.collapsed", JSON.stringify([...networks]));
|
|
|
|
},
|
|
|
|
getExpandLabel(network) {
|
|
|
|
return network.isCollapsed ? "Expand" : "Collapse";
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|