Fix inline channel links

This commit is contained in:
Pavel Djundik 2018-07-09 20:31:48 +03:00 committed by Pavel Djundik
parent f0390dae63
commit 1831e2e63e
4 changed files with 16 additions and 31 deletions

View File

@ -52,8 +52,8 @@ function addWhoisItem() {
function whois(itemData) { function whois(itemData) {
const chan = utils.findCurrentNetworkChan(itemData); const chan = utils.findCurrentNetworkChan(itemData);
if (chan.length) { if (chan) {
chan.click(); $(`#sidebar .chan[data-id="${chan.id}"]`).trigger("click");
} }
socket.emit("input", { socket.emit("input", {
@ -87,8 +87,8 @@ function addQueryItem() {
function query(itemData) { function query(itemData) {
const chan = utils.findCurrentNetworkChan(itemData); const chan = utils.findCurrentNetworkChan(itemData);
if (chan.length) { if (chan) {
chan.click(); $(`#sidebar .chan[data-id="${chan.id}"]`).trigger("click");
} }
socket.emit("input", { socket.emit("input", {

View File

@ -79,8 +79,8 @@ function handleKeybinds(networks) {
const key = form.find("input[name='key']").val(); const key = form.find("input[name='key']").val();
const existingChannel = utils.findCurrentNetworkChan(channel); const existingChannel = utils.findCurrentNetworkChan(channel);
if (existingChannel.length) { if (existingChannel) {
existingChannel.trigger("click"); $(`#sidebar .chan[data-id="${chan.id}"]`).trigger("click");
} else { } else {
socket.emit("input", { socket.emit("input", {
text: `/join ${channel} ${key}`, text: `/join ${channel} ${key}`,

View File

@ -21,8 +21,6 @@ window.vueMounted = () => {
require("./clipboard"); require("./clipboard");
const sidebar = $("#sidebar, #footer"); const sidebar = $("#sidebar, #footer");
const chat = $("#chat");
const viewport = $("#viewport"); const viewport = $("#viewport");
function storeSidebarVisibility(name, state) { function storeSidebarVisibility(name, state) {
@ -101,16 +99,16 @@ window.vueMounted = () => {
$(document.body).addClass("is-apple"); $(document.body).addClass("is-apple");
} }
chat.on("click", ".inline-channel", function() { viewport.on("click", ".inline-channel", function() {
const name = $(this).attr("data-chan"); const name = $(this).attr("data-chan");
const chan = utils.findCurrentNetworkChan(name); const chan = utils.findCurrentNetworkChan(name);
if (chan.length) { if (chan) {
chan.trigger("click"); $(`#sidebar .chan[data-id="${chan.id}"]`).trigger("click");
} }
socket.emit("input", { socket.emit("input", {
target: chat.data("id"), target: vueApp.activeChannel.channel.id,
text: "/join " + name, text: "/join " + name,
}); });
}); });
@ -130,16 +128,7 @@ window.vueMounted = () => {
let channel; let channel;
if (inSidebar) { if (inSidebar) {
chat.data( channel = findChannel(Number(self.attr("data-id")));
"id",
self.data("id")
);
socket.emit(
"open",
self.data("id")
);
channel = findChannel(self.data("id"));
vueApp.activeChannel = channel; vueApp.activeChannel = channel;
@ -148,6 +137,8 @@ window.vueMounted = () => {
channel.channel.unread = 0; channel.channel.unread = 0;
} }
socket.emit("open", channel ? channel.channel.id : null);
let hasAnyHighlights = false; let hasAnyHighlights = false;
for (const network of vueApp.networks) { for (const network of vueApp.networks) {

View File

@ -31,13 +31,7 @@ module.exports = {
function findCurrentNetworkChan(name) { function findCurrentNetworkChan(name) {
name = name.toLowerCase(); name = name.toLowerCase();
return $(".network .chan.active") return vueApp.activeChannel.network.channels.find((c) => c.name.toLowerCase() === name);
.parent(".network")
.find(".chan")
.filter(function() {
return $(this).attr("aria-label").toLowerCase() === name;
})
.first();
} }
function resetHeight(element) { function resetHeight(element) {
@ -80,8 +74,8 @@ function join(args) {
if (channel) { if (channel) {
const chan = findCurrentNetworkChan(channel); const chan = findCurrentNetworkChan(channel);
if (chan.length) { if (chan) {
chan.trigger("click"); $(`#sidebar .chan[data-id="${chan.id}"]`).trigger("click");
} }
} }
} }