From e845e17a636fb35df68bb6bce155c290325bc1e5 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Fri, 25 Oct 2019 14:14:20 +0300 Subject: [PATCH] Convert some clicks to router push --- client/js/commands/join.js | 4 +--- client/js/contextMenuFactory.js | 4 ++-- client/js/keybinds.js | 2 +- client/js/socket-events/join.js | 5 +---- client/js/socket-events/msg_special.js | 6 +----- client/js/socket-events/network.js | 9 +-------- client/js/socket-events/part.js | 6 +----- 7 files changed, 8 insertions(+), 28 deletions(-) diff --git a/client/js/commands/join.js b/client/js/commands/join.js index 51780d9b..09eb4c86 100644 --- a/client/js/commands/join.js +++ b/client/js/commands/join.js @@ -1,7 +1,5 @@ "use strict"; -const $ = require("jquery"); - exports.input = function(args) { const utils = require("../utils"); const socket = require("../socket"); @@ -27,7 +25,7 @@ exports.input = function(args) { const chan = utils.findCurrentNetworkChan(channels); if (chan) { - $(`#sidebar .chan[data-id="${chan.id}"]`).trigger("click"); + vueApp.$router.push("chan-" + chan.id); } else { socket.emit("input", { text: `/join ${channels} ${args.length > 1 ? args[1] : ""}`, diff --git a/client/js/contextMenuFactory.js b/client/js/contextMenuFactory.js index 057493f4..7e473a12 100644 --- a/client/js/contextMenuFactory.js +++ b/client/js/contextMenuFactory.js @@ -50,7 +50,7 @@ function addWhoisItem() { const chan = utils.findCurrentNetworkChan(itemData); if (chan) { - $(`#sidebar .chan[data-id="${chan.id}"]`).trigger("click"); + vueApp.$router.push("chan-" + chan.id); } socket.emit("input", { @@ -85,7 +85,7 @@ function addQueryItem() { const chan = utils.findCurrentNetworkChan(itemData); if (chan) { - $(`#sidebar .chan[data-id="${chan.id}"]`).trigger("click"); + vueApp.$router.push("chan-" + chan.id); } socket.emit("input", { diff --git a/client/js/keybinds.js b/client/js/keybinds.js index e16043e1..6a1162cf 100644 --- a/client/js/keybinds.js +++ b/client/js/keybinds.js @@ -90,7 +90,7 @@ Mousetrap.bind(["alt+a"], function() { } if (targetchan) { - $(`#sidebar .chan[data-id="${targetchan.id}"]`).trigger("click"); + vueApp.$router.push("chan-" + targetchan.id); } return false; diff --git a/client/js/socket-events/join.js b/client/js/socket-events/join.js index bcff04cc..25393c95 100644 --- a/client/js/socket-events/join.js +++ b/client/js/socket-events/join.js @@ -1,6 +1,5 @@ "use strict"; -const $ = require("jquery"); const socket = require("../socket"); const {vueApp, initChannel} = require("../vue"); @@ -16,7 +15,5 @@ socket.on("join", function(data) { return; } - vueApp.$nextTick(() => { - $(`#sidebar .chan[data-id="${data.chan.id}"]`).trigger("click"); - }); + vueApp.$router.push("chan-" + data.chan.id); }); diff --git a/client/js/socket-events/msg_special.js b/client/js/socket-events/msg_special.js index 2e05c095..22706492 100644 --- a/client/js/socket-events/msg_special.js +++ b/client/js/socket-events/msg_special.js @@ -1,13 +1,9 @@ "use strict"; -const $ = require("jquery"); const socket = require("../socket"); const {vueApp, findChannel} = require("../vue"); socket.on("msg:special", function(data) { findChannel(data.chan).channel.data = data.data; - - vueApp.$nextTick(() => { - $(`#sidebar .chan[data-id="${data.chan}"]`).trigger("click"); - }); + vueApp.$router.push("chan-" + data.chan); }); diff --git a/client/js/socket-events/network.js b/client/js/socket-events/network.js index 1e823af6..41cc58b0 100644 --- a/client/js/socket-events/network.js +++ b/client/js/socket-events/network.js @@ -2,7 +2,6 @@ const $ = require("jquery"); const socket = require("../socket"); -const sidebar = $("#sidebar"); const {vueApp, initChannel, findChannel} = require("../vue"); socket.on("network", function(data) { @@ -13,13 +12,7 @@ socket.on("network", function(data) { network.channels.forEach(initChannel); vueApp.networks.push(network); - - vueApp.$nextTick(() => { - sidebar - .find(".chan") - .last() - .trigger("click"); - }); + vueApp.$router.push("chan-" + network.channels[0].id); $("#connect") .find(".btn") diff --git a/client/js/socket-events/part.js b/client/js/socket-events/part.js index 7d5607e9..064b05e6 100644 --- a/client/js/socket-events/part.js +++ b/client/js/socket-events/part.js @@ -1,16 +1,12 @@ "use strict"; -const $ = require("jquery"); const socket = require("../socket"); const {vueApp, findChannel} = require("../vue"); socket.on("part", function(data) { // When parting from the active channel/query, jump to the network's lobby if (vueApp.activeChannel && vueApp.activeChannel.channel.id === data.chan) { - $("#sidebar .chan[data-id='" + data.chan + "']") - .closest(".network") - .find(".lobby") - .trigger("click"); + vueApp.$router.push("chan-" + vueApp.activeChannel.network.id); } const channel = findChannel(data.chan);