Convert some clicks to router push

This commit is contained in:
Pavel Djundik 2019-10-25 14:14:20 +03:00
parent c6dca616e6
commit e845e17a63
7 changed files with 8 additions and 28 deletions

View File

@ -1,7 +1,5 @@
"use strict"; "use strict";
const $ = require("jquery");
exports.input = function(args) { exports.input = function(args) {
const utils = require("../utils"); const utils = require("../utils");
const socket = require("../socket"); const socket = require("../socket");
@ -27,7 +25,7 @@ exports.input = function(args) {
const chan = utils.findCurrentNetworkChan(channels); const chan = utils.findCurrentNetworkChan(channels);
if (chan) { if (chan) {
$(`#sidebar .chan[data-id="${chan.id}"]`).trigger("click"); vueApp.$router.push("chan-" + chan.id);
} else { } else {
socket.emit("input", { socket.emit("input", {
text: `/join ${channels} ${args.length > 1 ? args[1] : ""}`, text: `/join ${channels} ${args.length > 1 ? args[1] : ""}`,

View File

@ -50,7 +50,7 @@ function addWhoisItem() {
const chan = utils.findCurrentNetworkChan(itemData); const chan = utils.findCurrentNetworkChan(itemData);
if (chan) { if (chan) {
$(`#sidebar .chan[data-id="${chan.id}"]`).trigger("click"); vueApp.$router.push("chan-" + chan.id);
} }
socket.emit("input", { socket.emit("input", {
@ -85,7 +85,7 @@ function addQueryItem() {
const chan = utils.findCurrentNetworkChan(itemData); const chan = utils.findCurrentNetworkChan(itemData);
if (chan) { if (chan) {
$(`#sidebar .chan[data-id="${chan.id}"]`).trigger("click"); vueApp.$router.push("chan-" + chan.id);
} }
socket.emit("input", { socket.emit("input", {

View File

@ -90,7 +90,7 @@ Mousetrap.bind(["alt+a"], function() {
} }
if (targetchan) { if (targetchan) {
$(`#sidebar .chan[data-id="${targetchan.id}"]`).trigger("click"); vueApp.$router.push("chan-" + targetchan.id);
} }
return false; return false;

View File

@ -1,6 +1,5 @@
"use strict"; "use strict";
const $ = require("jquery");
const socket = require("../socket"); const socket = require("../socket");
const {vueApp, initChannel} = require("../vue"); const {vueApp, initChannel} = require("../vue");
@ -16,7 +15,5 @@ socket.on("join", function(data) {
return; return;
} }
vueApp.$nextTick(() => { vueApp.$router.push("chan-" + data.chan.id);
$(`#sidebar .chan[data-id="${data.chan.id}"]`).trigger("click");
});
}); });

View File

@ -1,13 +1,9 @@
"use strict"; "use strict";
const $ = require("jquery");
const socket = require("../socket"); const socket = require("../socket");
const {vueApp, findChannel} = require("../vue"); const {vueApp, findChannel} = require("../vue");
socket.on("msg:special", function(data) { socket.on("msg:special", function(data) {
findChannel(data.chan).channel.data = data.data; findChannel(data.chan).channel.data = data.data;
vueApp.$router.push("chan-" + data.chan);
vueApp.$nextTick(() => {
$(`#sidebar .chan[data-id="${data.chan}"]`).trigger("click");
});
}); });

View File

@ -2,7 +2,6 @@
const $ = require("jquery"); const $ = require("jquery");
const socket = require("../socket"); const socket = require("../socket");
const sidebar = $("#sidebar");
const {vueApp, initChannel, findChannel} = require("../vue"); const {vueApp, initChannel, findChannel} = require("../vue");
socket.on("network", function(data) { socket.on("network", function(data) {
@ -13,13 +12,7 @@ socket.on("network", function(data) {
network.channels.forEach(initChannel); network.channels.forEach(initChannel);
vueApp.networks.push(network); vueApp.networks.push(network);
vueApp.$router.push("chan-" + network.channels[0].id);
vueApp.$nextTick(() => {
sidebar
.find(".chan")
.last()
.trigger("click");
});
$("#connect") $("#connect")
.find(".btn") .find(".btn")

View File

@ -1,16 +1,12 @@
"use strict"; "use strict";
const $ = require("jquery");
const socket = require("../socket"); const socket = require("../socket");
const {vueApp, findChannel} = require("../vue"); const {vueApp, findChannel} = require("../vue");
socket.on("part", function(data) { socket.on("part", function(data) {
// When parting from the active channel/query, jump to the network's lobby // When parting from the active channel/query, jump to the network's lobby
if (vueApp.activeChannel && vueApp.activeChannel.channel.id === data.chan) { if (vueApp.activeChannel && vueApp.activeChannel.channel.id === data.chan) {
$("#sidebar .chan[data-id='" + data.chan + "']") vueApp.$router.push("chan-" + vueApp.activeChannel.network.id);
.closest(".network")
.find(".lobby")
.trigger("click");
} }
const channel = findChannel(data.chan); const channel = findChannel(data.chan);