hardlounge/client/components/InlineChannel.vue
Pavel Djundik 2f635069e0 Move vuex state to a separate file and reorganize some code
Co-Authored-By: Tim Miller-Williams <timmw@users.noreply.github.com>
2019-11-25 20:12:54 +02:00

34 lines
756 B
Vue

<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.$store.state.activeChannel.network.channels.find(
(c) => c.name.toLowerCase() === channelToFind
);
if (existingChannel) {
this.$root.switchToChannel(existingChannel);
}
// TODO: Required here because it breaks tests
const socket = require("../js/socket");
socket.emit("input", {
target: this.$store.state.activeChannel.channel.id,
text: "/join " + this.channel,
});
},
},
};
</script>