mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-08 23:30:53 +00:00
4.0.0-rc13.16
* Added: Option to display rich embeds in chat for all links and not just those to Twitch Clips and Videos. (Closes #554) * Added: Option to only display rich embeds for links posted by users of a certain level. (Broadcaster, VIP, etc.) * Fixed: Implement logic for determining if embedded chat is dark or not, since embedded chat is a special snowflake. (Closes #557) * Fixed: Emote Alignment setting broke due to DOM changes in last update. (Closes #555)
This commit is contained in:
parent
9117ac89d2
commit
d0789481fa
12 changed files with 375 additions and 245 deletions
|
@ -149,7 +149,7 @@ ${typeof x[1] === 'string' ? x[1] : JSON.stringify(x[1], null, 4)}`
|
|||
FrankerFaceZ.Logger = Logger;
|
||||
|
||||
const VER = FrankerFaceZ.version_info = {
|
||||
major: 4, minor: 0, revision: 0, extra: '-rc13.15',
|
||||
major: 4, minor: 0, revision: 0, extra: '-rc13.16',
|
||||
commit: __git_commit__,
|
||||
build: __webpack_hash__,
|
||||
toString: () =>
|
||||
|
|
|
@ -125,6 +125,32 @@ export default class Chat extends Module {
|
|||
}
|
||||
});
|
||||
|
||||
this.settings.add('chat.rich.all-links', {
|
||||
default: false,
|
||||
ui: {
|
||||
path: 'Chat > Appearance >> Rich Content',
|
||||
title: 'Display rich content embeds for all links.',
|
||||
component: 'setting-check-box'
|
||||
}
|
||||
});
|
||||
|
||||
this.settings.add('chat.rich.minimum-level', {
|
||||
default: 0,
|
||||
ui: {
|
||||
path: 'Chat > Appearance >> Rich Content',
|
||||
title: 'Required User Level',
|
||||
description: 'Only display rich content embeds on messages posted by users with this level or higher.',
|
||||
component: 'setting-select-box',
|
||||
data: [
|
||||
{value: 4, title: 'Broadcaster'},
|
||||
{value: 3, title: 'Moderator'},
|
||||
{value: 2, title: 'VIP'},
|
||||
{value: 1, title: 'Subscriber'},
|
||||
{value: 0, title: 'Everyone'}
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
this.settings.add('chat.scrollback-length', {
|
||||
default: 150,
|
||||
ui: {
|
||||
|
@ -759,6 +785,26 @@ export default class Chat extends Module {
|
|||
}
|
||||
|
||||
|
||||
getUserLevel(msg) { // eslint-disable-line class-methods-use-this
|
||||
if ( ! msg || ! msg.user )
|
||||
return 0;
|
||||
|
||||
if ( msg.user.login === msg.roomLogin || msg.badges.broadcaster )
|
||||
return 4;
|
||||
|
||||
if ( msg.badges.moderator )
|
||||
return 3;
|
||||
|
||||
if ( msg.badges.vip )
|
||||
return 2;
|
||||
|
||||
if ( msg.badges.subscriber )
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
standardizeMessage(msg) { // eslint-disable-line class-methods-use-this
|
||||
if ( ! msg )
|
||||
return msg;
|
||||
|
@ -1007,15 +1053,15 @@ export default class Chat extends Module {
|
|||
}
|
||||
|
||||
|
||||
pluckRichContent(tokens) { // eslint-disable-line class-methods-use-this
|
||||
if ( ! this.context.get('chat.rich.enabled') )
|
||||
pluckRichContent(tokens, msg) { // eslint-disable-line class-methods-use-this
|
||||
if ( ! this.context.get('chat.rich.enabled') || this.context.get('chat.rich.minimum-level') > this.getUserLevel(msg) )
|
||||
return;
|
||||
|
||||
const providers = this.__rich_providers;
|
||||
|
||||
for(const token of tokens) {
|
||||
for(const provider of providers)
|
||||
if ( provider.test.call(this, token) ) {
|
||||
if ( provider.test.call(this, token, msg) ) {
|
||||
token.hidden = this.context.get('chat.rich.hide-tokens') && provider.hide_token;
|
||||
return provider.process.call(this, token);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,43 @@ import GET_CLIP from './clip_info.gql';
|
|||
import GET_VIDEO from './video_info.gql';
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// General Links
|
||||
// ============================================================================
|
||||
|
||||
export const Links = {
|
||||
type: 'link',
|
||||
hide_token: false,
|
||||
priority: -10,
|
||||
|
||||
test(token) {
|
||||
if ( ! this.context.get('chat.rich.all-links') )
|
||||
return false;
|
||||
|
||||
return token.type === 'link'
|
||||
},
|
||||
|
||||
process(token) {
|
||||
return {
|
||||
card_tooltip: true,
|
||||
url: token.url,
|
||||
|
||||
getData: async () => {
|
||||
const data = await this.get_link_info(token.url);
|
||||
|
||||
return {
|
||||
url: token.url,
|
||||
image: this.context.get('tooltip.link-images') ? (data.image_safe || this.context.get('tooltip.link-nsfw-images') ) ? data.preview || data.image : null : null,
|
||||
title: data.title,
|
||||
desc_1: data.desc_1,
|
||||
desc_2: data.desc_2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ============================================================================
|
||||
// Clips
|
||||
// ============================================================================
|
||||
|
|
|
@ -36,6 +36,10 @@ export default class Line extends Module {
|
|||
this.chat.context.on('changed:chat.badges.custom-mod', this.updateLines, this);
|
||||
this.chat.context.on('changed:chat.rich.enabled', this.updateLines, this);
|
||||
this.chat.context.on('changed:chat.rich.hide-tokens', this.updateLines, this);
|
||||
this.chat.context.on('changed:chat.rich.all-links', this.updateLines, this);
|
||||
this.chat.context.on('changed:chat.rich.minimum-level', this.updateLines, this);
|
||||
this.chat.context.on('changed:tooltip.link-images', this.maybeUpdateLines, this);
|
||||
this.chat.context.on('changed:tooltip.link-nsfw-images', this.maybeUpdateLines, this);
|
||||
|
||||
this.ChatLine.ready((cls, instances) => {
|
||||
const t = this,
|
||||
|
@ -85,6 +89,12 @@ export default class Line extends Module {
|
|||
}
|
||||
|
||||
|
||||
maybeUpdateLines() {
|
||||
if ( this.chat.context.get('chat.rich.all-links') )
|
||||
this.updateLines();
|
||||
}
|
||||
|
||||
|
||||
updateLines() {
|
||||
for(const inst of this.ChatLine.instances) {
|
||||
const msg = inst.props.node;
|
||||
|
|
|
@ -206,6 +206,7 @@ Twilight.ROUTES = {
|
|||
'prime': '/prime',
|
||||
'turbo': '/turbo',
|
||||
'user': '/:userName',
|
||||
'embed-chat': '/embed/:userName/chat'
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -58,6 +58,10 @@ export default class ChatLine extends Module {
|
|||
this.chat.context.on('changed:chat.rituals.show', this.updateLines, this);
|
||||
this.chat.context.on('changed:chat.rich.enabled', this.updateLines, this);
|
||||
this.chat.context.on('changed:chat.rich.hide-tokens', this.updateLines, this);
|
||||
this.chat.context.on('changed:chat.rich.all-links', this.updateLines, this);
|
||||
this.chat.context.on('changed:chat.rich.minimum-level', this.updateLines, this);
|
||||
this.chat.context.on('changed:tooltip.link-images', this.maybeUpdateLines, this);
|
||||
this.chat.context.on('changed:tooltip.link-nsfw-images', this.maybeUpdateLines, this);
|
||||
this.chat.context.on('changed:chat.actions.inline', this.updateLines, this);
|
||||
this.chat.context.on('changed:chat.filtering.show-deleted', this.updateLines, this);
|
||||
this.chat.context.on('changed:chat.filtering.process-own', this.updateLines, this);
|
||||
|
@ -433,6 +437,11 @@ export default class ChatLine extends Module {
|
|||
}
|
||||
|
||||
|
||||
maybeUpdateLines() {
|
||||
if ( this.chat.context.get('chat.rich.all-links') )
|
||||
this.updateLines();
|
||||
}
|
||||
|
||||
updateLines() {
|
||||
for(const inst of this.ChatLine.instances) {
|
||||
const msg = inst.props.message;
|
||||
|
|
|
@ -140,11 +140,23 @@ export default class RichContent extends Module {
|
|||
</div>)
|
||||
}
|
||||
|
||||
renderCardBody() {
|
||||
if ( this.props.renderBody )
|
||||
return this.props.renderBody(this.state, this, createElement);
|
||||
|
||||
if ( this.state.html )
|
||||
return <div dangerouslySetInnerHTML={{__html: this.state.html}} />;
|
||||
|
||||
return [
|
||||
this.renderCardImage(),
|
||||
this.renderCardDescription()
|
||||
];
|
||||
}
|
||||
|
||||
renderCard() {
|
||||
return (<div class="ffz--chat-card tw-elevation-1 tw-mg-t">
|
||||
<div class="tw-c-background-base tw-flex tw-flex-nowrap tw-pd-05">
|
||||
{this.renderCardImage()}
|
||||
{this.renderCardDescription()}
|
||||
{this.renderCardBody()}
|
||||
</div>
|
||||
</div>)
|
||||
}
|
||||
|
@ -153,8 +165,13 @@ export default class RichContent extends Module {
|
|||
if ( ! this.state.url )
|
||||
return this.renderCard();
|
||||
|
||||
const tooltip = this.props.card_tooltip;
|
||||
|
||||
return (<a
|
||||
class="chat-card__link"
|
||||
class={`${tooltip ? 'ffz-tooltip ' : ''} chat-card__link`}
|
||||
data-tooltip-type="link"
|
||||
data-url={this.state.url}
|
||||
data-is-mail={false}
|
||||
target="_blank"
|
||||
rel="noreferrer noopener"
|
||||
href={this.state.url}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
.message > .chat-line__message--emote {
|
||||
.message > span > .chat-line__message--emote {
|
||||
vertical-align: baseline;
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
.message > .chat-line__message--emote.ffz-emoji {
|
||||
.message > span > .chat-line__message--emote.ffz-emoji {
|
||||
padding-top: 0px;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
.message > .chat-line__message--emote {
|
||||
.message > span > .chat-line__message--emote {
|
||||
margin: -1px 0 0;
|
||||
}
|
||||
|
|
|
@ -52,8 +52,11 @@ This is a very early feature and will change as there is time.`,
|
|||
});
|
||||
|
||||
this.settings.add('theme.is-dark', {
|
||||
requires: ['theme.can-dark', 'context.ui.theme', 'context.ui.theatreModeEnabled'],
|
||||
requires: ['theme.can-dark', 'context.ui.theme', 'context.ui.theatreModeEnabled', 'context.route.name', 'context.location.search'],
|
||||
process(ctx) {
|
||||
if ( ctx.get('context.route.name') === 'embed-chat' )
|
||||
return (ctx.get('context.location.search')||'').includes('dark');
|
||||
|
||||
return ctx.get('context.ui.theatreModeEnabled') || (ctx.get('theme.can-dark') && ctx.get('context.ui.theme') === 1);
|
||||
},
|
||||
changed: () => this.updateCSS()
|
||||
|
|
|
@ -42,7 +42,15 @@
|
|||
}
|
||||
}
|
||||
|
||||
.ffz-tooltip.chat-card__link > * {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.ffz--chat-card {
|
||||
.chat-card__title {
|
||||
max-width: unset;
|
||||
}
|
||||
|
||||
.ffz--two-line {
|
||||
.tw-ellipsis { line-height: 1.4rem }
|
||||
.chat-card__title { line-height: 1.5rem }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue