From 771739cf945a79d4d02391c4de03f51a3de2c1ef Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Wed, 11 Jul 2018 10:54:32 +0300 Subject: [PATCH] Port ignore list to Vue --- client/components/Chat.vue | 2 ++ client/components/Special/ListIgnored.vue | 27 +++++++++++++++++++++++ client/js/libs/handlebars/parse.js | 7 +----- client/views/actions/channel_list.tpl | 18 --------------- client/views/actions/ignore_list.tpl | 16 -------------- src/plugins/inputs/ignore.js | 21 +++++++++++------- 6 files changed, 43 insertions(+), 48 deletions(-) create mode 100644 client/components/Special/ListIgnored.vue delete mode 100644 client/views/actions/channel_list.tpl delete mode 100644 client/views/actions/ignore_list.tpl diff --git a/client/components/Chat.vue b/client/components/Chat.vue index 79940196..d9bff463 100644 --- a/client/components/Chat.vue +++ b/client/components/Chat.vue @@ -91,6 +91,7 @@ import ChatInput from "./ChatInput.vue"; import ChatUserList from "./ChatUserList.vue"; import ListBans from "./Special/ListBans.vue"; import ListChannels from "./Special/ListChannels.vue"; +import ListIgnored from "./Special/ListIgnored.vue"; export default { name: "Chat", @@ -109,6 +110,7 @@ export default { switch (this.channel.special) { case "list_bans": return ListBans; case "list_channels": return ListChannels; + case "list_ignored": return ListIgnored; } }, }, diff --git a/client/components/Special/ListIgnored.vue b/client/components/Special/ListIgnored.vue new file mode 100644 index 00000000..4da5a5db --- /dev/null +++ b/client/components/Special/ListIgnored.vue @@ -0,0 +1,27 @@ + + + diff --git a/client/js/libs/handlebars/parse.js b/client/js/libs/handlebars/parse.js index 0a08769a..1c681452 100644 --- a/client/js/libs/handlebars/parse.js +++ b/client/js/libs/handlebars/parse.js @@ -64,12 +64,7 @@ function createFragment(fragment) { // Transform an IRC message potentially filled with styling control codes, URLs, // nicknames, and channels into a string of HTML elements to display on the client. -module.exports = function parse(text, users) { - // if it's not the users we're expecting, but rather is passed from Handlebars (occurs when users passed to template is null or undefined) - if (users && users.hash) { - users = []; - } - +module.exports = function parse(text, users = []) { // Extract the styling information and get the plain text version from it const styleFragments = parseStyle(text); const cleanText = styleFragments.map((fragment) => fragment.text).join(""); diff --git a/client/views/actions/channel_list.tpl b/client/views/actions/channel_list.tpl deleted file mode 100644 index 8fab73d0..00000000 --- a/client/views/actions/channel_list.tpl +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - {{#each channels}} - - - - - - {{/each}} - -
ChannelUsersTopic
{{{parse channel}}}{{num_users}}{{{parse topic}}}
diff --git a/client/views/actions/ignore_list.tpl b/client/views/actions/ignore_list.tpl deleted file mode 100644 index 88e0e70b..00000000 --- a/client/views/actions/ignore_list.tpl +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - {{#each ignored}} - - - - - {{/each}} - -
HostmaskIgnored At
{{hostmask}}{{{localetime when}}}
diff --git a/src/plugins/inputs/ignore.js b/src/plugins/inputs/ignore.js index 4b999570..0f3c731a 100644 --- a/src/plugins/inputs/ignore.js +++ b/src/plugins/inputs/ignore.js @@ -92,27 +92,32 @@ exports.input = function(network, chan, cmd, args) { })); } else { const chanName = "Ignored users"; + const ignored = network.ignoreList.map((data) => ({ + hostmask: `${data.nick}!${data.ident}@${data.hostname}`, + when: data.when, + })); let newChan = network.getChannel(chanName); if (typeof newChan === "undefined") { newChan = client.createChannel({ type: Chan.Type.SPECIAL, + special: Chan.SpecialType.IGNORELIST, name: chanName, + data: ignored, }); client.emit("join", { network: network.uuid, chan: newChan.getFilteredClone(true), index: network.addChannel(newChan), }); - } + } else { + newChan.data = ignored; - newChan.pushMessage(client, new Msg({ - type: Msg.Type.IGNORELIST, - ignored: network.ignoreList.map((data) => ({ - hostmask: `${data.nick}!${data.ident}@${data.hostname}`, - when: data.when, - })), - }), true); + client.emit("msg:special", { + chan: newChan.id, + data: ignored, + }); + } } break;