From c836d33abaddbcf8f26457892fdb9bec31d05c96 Mon Sep 17 00:00:00 2001 From: gr3ger Date: Fri, 25 Sep 2020 20:19:27 +0200 Subject: [PATCH] Toggle highlighting works, it's just very basic --- src/modules/chat/actions/index.jsx | 3 ++- src/modules/chat/actions/types.jsx | 33 ++++++++++++++++++++++++++++++ src/modules/chat/tokenizers.jsx | 7 +++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/modules/chat/actions/index.jsx b/src/modules/chat/actions/index.jsx index b12cea47..e40d88db 100644 --- a/src/modules/chat/actions/index.jsx +++ b/src/modules/chat/actions/index.jsx @@ -69,7 +69,8 @@ export default class Actions extends Module { {v: {action: 'unban', appearance: {type: 'icon', icon: 'ffz-i-ok'}, options: {}, display: {mod: true, mod_icons: true, deleted: true}}}, {v: {action: 'timeout', appearance: {type: 'icon', icon: 'ffz-i-clock'}, display: {mod: true, mod_icons: true}}}, {v: {action: 'msg_delete', appearance: {type: 'icon', icon: 'ffz-i-trash'}, options: {}, display: {mod: true, mod_icons: true}}}, - {v: {action: 'reply', appearance: {type: 'icon', icon: 'ffz-i-reply'}, options: {}, display: {}}} + {v: {action: 'reply', appearance: {type: 'icon', icon: 'ffz-i-reply'}, options: {}, display: {}}}, + {v: {action: 'highlight', appearance: {type: 'icon', icon: 'ffz-i-eye'}, options: {}, display: {}}} ], type: 'array_merge', diff --git a/src/modules/chat/actions/types.jsx b/src/modules/chat/actions/types.jsx index b509da79..e33d572a 100644 --- a/src/modules/chat/actions/types.jsx +++ b/src/modules/chat/actions/types.jsx @@ -354,6 +354,39 @@ export const untimeout = { } } +export const highlight = { + presets: [{ + appearance: { + type: 'icon', + icon: 'ffz-i-eye' + }, + }], + + defaults: {}, + + required_context: ['user'], + + title: 'Highlight User', + + tooltip(data) { + return this.i18n.t('chat.actions.highlight.tooltip', 'Highlight {user.login}', {user: data}); + }, + + click(event, data) { + let key = 'chat.filtering.highlight-temp' + let val = this.settings.provider.get(key) + if(!val) + val = [] + if(val.includes(data.user.id)) + val = val.filter(value => value !== data.user.id); + else + val.push(data.user.id) + this.settings.provider.set(key, val) + } +} + + + // ============================================================================ // Whisper diff --git a/src/modules/chat/tokenizers.jsx b/src/modules/chat/tokenizers.jsx index 9d029eb1..4481363f 100644 --- a/src/modules/chat/tokenizers.jsx +++ b/src/modules/chat/tokenizers.jsx @@ -433,6 +433,13 @@ export const UserHighlights = { } } + if(this.context.manager.provider.get('chat.filtering.highlight-temp')?.includes(msg.user.userID)) + { + (msg.highlights = (msg.highlights || new Set())).add('user'); + msg.mentioned = true; + return tokens; + } + return tokens; } }