Only send /join for current channel if there are no arguments

This commit is contained in:
Pavel Djundik 2018-09-25 19:52:22 +03:00
parent 7ba14fe4e3
commit 5f0f745d10

View File

@ -3,18 +3,22 @@
const $ = require("jquery"); const $ = require("jquery");
exports.input = function(args) { exports.input = function(args) {
const channel = args[0];
const utils = require("../utils"); const utils = require("../utils");
const socket = require("../socket"); const socket = require("../socket");
const {vueApp} = require("../vue"); const {vueApp} = require("../vue");
if (channel) { if (args.length > 0) {
const channel = args[0];
if (channel.length > 0) {
const chan = utils.findCurrentNetworkChan(channel); const chan = utils.findCurrentNetworkChan(channel);
if (chan) { if (chan) {
$(`#sidebar .chan[data-id="${chan.id}"]`).trigger("click"); $(`#sidebar .chan[data-id="${chan.id}"]`).trigger("click");
} }
}
} else if (vueApp.activeChannel.channel.type === "channel") { } else if (vueApp.activeChannel.channel.type === "channel") {
// If `/join` command is used without any arguments, re-join current channel
socket.emit("input", { socket.emit("input", {
target: vueApp.activeChannel.channel.id, target: vueApp.activeChannel.channel.id,
text: `/join ${vueApp.activeChannel.channel.name}`, text: `/join ${vueApp.activeChannel.channel.name}`,