mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-07-31 23:18:31 +00:00
4.0.0-rc21.7
* Added: Option to open viewer cards when clicking a mention in chat. * Fixed: Mention matching in chat. (Now using the same regular expression as vanilla Twitch.)
This commit is contained in:
parent
f754b7fce7
commit
b73234453b
6 changed files with 101 additions and 27 deletions
|
@ -45,6 +45,7 @@ export default class Chat extends Module {
|
|||
|
||||
// Bind for JSX stuff
|
||||
this.clickToReveal = this.clickToReveal.bind(this);
|
||||
this.handleMentionClick = this.handleMentionClick.bind(this);
|
||||
|
||||
this.style = new ManagedStyle;
|
||||
|
||||
|
@ -582,6 +583,16 @@ export default class Chat extends Module {
|
|||
});
|
||||
|
||||
|
||||
this.settings.add('chat.filtering.clickable-mentions', {
|
||||
default: false,
|
||||
ui: {
|
||||
component: 'setting-check-box',
|
||||
path: 'Chat > Filtering >> Appearance',
|
||||
title: 'Enable opening viewer cards by clicking mentions in chat.'
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
this.settings.add('chat.filtering.highlight-mentions', {
|
||||
default: false,
|
||||
ui: {
|
||||
|
@ -950,6 +961,32 @@ export default class Chat extends Module {
|
|||
}
|
||||
|
||||
|
||||
handleMentionClick(event) {
|
||||
if ( ! this.context.get('chat.filtering.clickable-mentions') )
|
||||
return;
|
||||
|
||||
const target = event.target,
|
||||
ds = target && target.dataset;
|
||||
|
||||
if ( ! ds || ! ds.login )
|
||||
return;
|
||||
|
||||
const fine = this.resolve('site.fine');
|
||||
if ( ! fine )
|
||||
return;
|
||||
|
||||
const chat = fine.searchParent(event.target, n => n.props && n.props.onUsernameClick);
|
||||
if ( ! chat )
|
||||
return;
|
||||
|
||||
chat.props.onUsernameClick(
|
||||
ds.login,
|
||||
undefined, undefined,
|
||||
event.currentTarget.getBoundingClientRect().bottom
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
clickToReveal(event) {
|
||||
const target = event.target;
|
||||
if ( target ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue