1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-09-01 02:40:56 +00:00

Add support for asynchronously loaded rich content blocks in chat.

This commit is contained in:
SirStendec 2018-04-03 19:28:06 -04:00
parent 9aafff3a14
commit d1acc9f7cc
9 changed files with 419 additions and 5 deletions

View file

@ -8,6 +8,8 @@ import Twilight from 'site';
import Module from 'utilities/module';
//import {Color} from 'utilities/color';
import RichContent from './rich_content';
const SUB_TIERS = {
1000: 1,
2000: 2,
@ -23,6 +25,7 @@ export default class ChatLine extends Module {
this.inject('chat');
this.inject('site.fine');
this.inject('site.web_munch');
this.inject(RichContent);
this.ChatLine = this.fine.define(
'chat-line',
@ -43,13 +46,16 @@ export default class ChatLine extends Module {
this.chat.context.on('changed:chat.badges.hidden', this.updateLines, this);
this.chat.context.on('changed:chat.badges.custom-mod', this.updateLines, this);
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);
const t = this,
React = this.web_munch.getModule('react');
if ( ! React )
return;
const e = React.createElement;
const e = React.createElement,
FFZRichContent = this.rich_content && this.rich_content.RichContent;
this.ChatLine.ready(cls => {
cls.prototype.shouldComponentUpdate = function(props, state) {
@ -101,7 +107,12 @@ export default class ChatLine extends Module {
if ( ! msg.message && msg.messageParts )
detokenizeMessage(msg);
const tokens = msg.ffz_tokens = msg.ffz_tokens || t.chat.tokenizeMessage(msg, {login: this.props.currentUserLogin, display: this.props.currentUserDisplayName});
const u = {
login: this.props.currentUserLogin,
display: this.props.currentUserDisplayName
},
tokens = msg.ffz_tokens = msg.ffz_tokens || t.chat.tokenizeMessage(msg, u),
rich_content = FFZRichContent && t.chat.pluckRichContent(tokens, msg);
let cls = 'chat-line__message',
out = (tokens.length || ! msg.ffz_type) ? [
@ -136,6 +147,8 @@ export default class ChatLine extends Module {
onClick: this.alwaysShowMessage
}, `<message deleted>`)),
show && rich_content && e(FFZRichContent, rich_content),
/*this.state.renderDebug === 2 && e('div', {
className: 'border mg-t-05'
}, old_render.call(this)),