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