From c0cd337c1044b0d4876335b5269f6afe23c8e56d Mon Sep 17 00:00:00 2001 From: Sergei Ilinykh Date: Sun, 30 Jun 2024 14:10:21 +0300 Subject: [PATCH] More reactions fixes --- src/chatviewcommon.cpp | 6 +++++- themes/chatview/psi/bubble/index.html | 19 ++++++++++++++----- themes/chatview/util.js | 4 +++- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/chatviewcommon.cpp b/src/chatviewcommon.cpp index 933c93b0b..83fd57e63 100644 --- a/src/chatviewcommon.cpp +++ b/src/chatviewcommon.cpp @@ -155,7 +155,11 @@ ChatViewCommon::updateReactions(const QString &senderNickname, const QString &me msgIt.value().total[v].append(senderNickname); } for (auto const &v : toRemove) { - msgIt.value().total[v].removeOne(senderNickname); + auto it = msgIt.value().total.find(v); + it->removeOne(senderNickname); + if (it->isEmpty()) { + msgIt.value().total.erase(it); + } } auto &total = msgIt.value().total; diff --git a/themes/chatview/psi/bubble/index.html b/themes/chatview/psi/bubble/index.html index a39695241..9c47b9a72 100644 --- a/themes/chatview/psi/bubble/index.html +++ b/themes/chatview/psi/bubble/index.html @@ -111,7 +111,7 @@ function setupContextMenu() { chatMenu.addItemProvider((event) => { - const isNick = event.target.className == "nick"; + const isNick = event.target.classList.contains("nick"); let msgNode; if (!isNick) { msgNode = event.target; @@ -126,10 +126,14 @@ let items; if (isNick) { items = [ - { text: "Info", action: ()=>{ shared.session.showInfo(nick); } }, - { text: "Open Chat", action: ()=>{ shared.session.openChat(nick); } }, - { text: "Kick", action: ()=>{ shared.session.kick(nick); } } - ] + { text: "Info", action: ()=>{ shared.session.showInfo(nick); } } + ]; + if (shared.isMuc) { + items = items.concat([ + { text: "Open Chat", action: ()=>{ shared.session.openChat(nick); } }, + { text: "Kick", action: ()=>{ shared.session.kick(nick); } } + ]) + } } else { items = [ { text: "Delete", action: ()=>{ shared.session.deleteMessage(msgNode.id); } }, @@ -152,6 +156,11 @@ } let reactions = msg.getElementsByClassName("reactions").item(0); if (reactions) { + if (!event["reactions"].length) { + reactions.parentElement.removeChild(reactions.previousSibling); + reactions.parentElement.removeChild(reactions); + return; + } reactions.innerHTML = ""; } else { lineBreak = document.createElement("hr"); diff --git a/themes/chatview/util.js b/themes/chatview/util.js index 658a96458..6b12676a4 100644 --- a/themes/chatview/util.js +++ b/themes/chatview/util.js @@ -377,13 +377,15 @@ function initPsiTheme() { "🤣", "🔥", "👍", + "🤔", + "😱", "😭", "🙏", "❤️", "😘", "🥰", "😍", - "😊", + "😊" ] const rs = document.createElement("div");