hardlounge/client/components/InlineChannel.vue

35 lines
801 B
Vue
Raw Normal View History

2019-10-17 14:17:02 +00:00
<template>
<span class="inline-channel" dir="auto" role="button" tabindex="0" @click="onClick"
><slot></slot
></span>
</template>
<script>
export default {
name: "InlineChannel",
props: {
channel: String,
},
methods: {
onClick() {
const channelToFind = this.channel.toLowerCase();
const existingChannel = this.$root.activeChannel.network.channels.find(
(c) => c.name.toLowerCase() === channelToFind
);
if (existingChannel) {
const $ = require("jquery");
$(`#sidebar .chan[data-id="${existingChannel.id}"]`).trigger("click");
}
// TODO: Required here because it breaks tests
const socket = require("../js/socket");
socket.emit("input", {
target: this.$root.activeChannel.channel.id,
text: "/join " + this.channel,
});
},
},
};
</script>