From f974c230efb4222e92dc479782861e1f3f47abc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 5 May 2023 21:10:17 -0400 Subject: [PATCH] fix: chat ip button not doing anything if clicked outside of icon --- install/package.json | 6 +++--- public/src/client/chats.js | 24 +++++++++++------------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/install/package.json b/install/package.json index b8325f4745..5cbb66926c 100644 --- a/install/package.json +++ b/install/package.json @@ -100,10 +100,10 @@ "nodebb-plugin-ntfy": "1.0.15", "nodebb-plugin-spam-be-gone": "2.0.7", "nodebb-rewards-essentials": "0.2.3", - "nodebb-theme-harmony": "1.0.18", + "nodebb-theme-harmony": "1.0.19", "nodebb-theme-lavender": "7.0.9", - "nodebb-theme-peace": "2.0.21", - "nodebb-theme-persona": "13.0.63", + "nodebb-theme-peace": "2.0.22", + "nodebb-theme-persona": "13.0.64", "nodebb-widget-essentials": "7.0.12", "nodemailer": "6.9.1", "nprogress": "0.2.0", diff --git a/public/src/client/chats.js b/public/src/client/chats.js index 246754add5..98833e1e92 100644 --- a/public/src/client/chats.js +++ b/public/src/client/chats.js @@ -103,20 +103,18 @@ define('forum/chats', [ }; Chats.addIPHandler = function (container) { - container.on('click', '.chat-ip-button', function () { - const ipEl = $(this).parent(); + container.on('click', '.chat-ip-button', async function () { + const ipEl = $(this); + let ip = ipEl.attr('data-ip'); + if (ip) { + navigator.clipboard.writeText(ip); + ipEl.translateText('[[global:copied]]'); + setTimeout(() => ipEl.text(ip), 2000); + return; + } const mid = ipEl.parents('[data-mid]').attr('data-mid'); - socket.emit('modules.chats.getIP', mid, function (err, ip) { - if (err) { - return alerts.error(err); - } - ipEl.text(ip); - ipEl.on('click', () => { - navigator.clipboard.writeText(ip); - ipEl.translateText('[[global:copied]]'); - setTimeout(() => ipEl.text(ip), 2000); - }); - }); + ip = await socket.emit('modules.chats.getIP', mid); + ipEl.text(ip).attr('data-ip', ip); }); };