From 7216b8124b9f558afb36168ebb6d4b25932a8bf1 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Thu, 30 Jan 2020 10:57:38 +0200 Subject: [PATCH] Add context menu to clear channel history --- client/css/style.css | 1 + client/js/helpers/contextMenu.js | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/client/css/style.css b/client/css/style.css index c79224e8..73cae3ff 100644 --- a/client/css/style.css +++ b/client/css/style.css @@ -349,6 +349,7 @@ p { .context-menu-action-voice::before { content: "\f067"; /* http://fontawesome.io/icon/plus/ */ } .context-menu-network::before { content: "\f233"; /* https://fontawesome.com/icons/server?style=solid */ } .context-menu-edit::before { content: "\f303"; /* https://fontawesome.com/icons/pencil-alt?style=solid */ } +.context-menu-clear-history::before { content: "\f1f8"; /* https://fontawesome.com/icons/trash?style=solid */ } .channel-list-item .not-secure-icon::before { content: "\f071"; /* https://fontawesome.com/icons/exclamation-triangle?style=solid */ diff --git a/client/js/helpers/contextMenu.js b/client/js/helpers/contextMenu.js index 5c7d9066..0ca7b493 100644 --- a/client/js/helpers/contextMenu.js +++ b/client/js/helpers/contextMenu.js @@ -129,6 +129,27 @@ export function generateChannelContextMenu($root, channel, network) { }); } + if (channel.type === "channel" || channel.type === "query") { + items.push({ + label: "Clear history", + type: "item", + class: "clear-history", + action() { + // TODO: Confirmation window + + channel.messages = []; + channel.unread = 0; + channel.highlight = 0; + channel.firstUnread = 0; + channel.moreHistoryAvailable = false; + + socket.emit("history:clear", { + target: channel.id, + }); + }, + }); + } + // Add close menu item items.push({ label: closeMap[channel.type],