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";
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] : ""}`,

View File

@ -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", {

View File

@ -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;

View File

@ -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);
});

View File

@ -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);
});

View File

@ -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")

View File

@ -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);