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) {
const chan = utils.findCurrentNetworkChan(itemData);
if (chan.length) {
chan.click();
if (chan) {
$(`#sidebar .chan[data-id="${chan.id}"]`).trigger("click");
}
socket.emit("input", {
@ -87,8 +87,8 @@ function addQueryItem() {
function query(itemData) {
const chan = utils.findCurrentNetworkChan(itemData);
if (chan.length) {
chan.click();
if (chan) {
$(`#sidebar .chan[data-id="${chan.id}"]`).trigger("click");
}
socket.emit("input", {

View File

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

View File

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

View File

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