diff --git a/package.json b/package.json index d7a4749e..96ea692d 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "frankerfacez", "author": "Dan Salvato LLC", - "version": "4.18.6", + "version": "4.18.7", "description": "FrankerFaceZ is a Twitch enhancement suite.", "license": "Apache-2.0", "scripts": { diff --git a/src/modules/chat/badges.jsx b/src/modules/chat/badges.jsx index 2bbfe32b..f93418e0 100644 --- a/src/modules/chat/badges.jsx +++ b/src/modules/chat/badges.jsx @@ -645,7 +645,7 @@ export default class Badges extends Module { async loadGlobalBadges(tries = 0) { let response, data; - if ( this.experiments.getAssignment('api_load') ) + if ( this.experiments.getAssignment('api_load') && tries < 1 ) try { fetch(`${NEW_API}/v1/badges`).catch(() => {}); } catch(err) { /* do nothing */ } diff --git a/src/modules/chat/emotes.js b/src/modules/chat/emotes.js index d8b6d5ae..b4668e0c 100644 --- a/src/modules/chat/emotes.js +++ b/src/modules/chat/emotes.js @@ -542,7 +542,7 @@ export default class Emotes extends Module { async loadGlobalSets(tries = 0) { let response, data; - if ( this.experiments.getAssignment('api_load') ) + if ( this.experiments.getAssignment('api_load') && tries < 1 ) try { fetch(`${NEW_API}/v1/set/global`).catch(() => {}); } catch(err) { /* do nothing */ } diff --git a/src/sites/twitch-twilight/index.js b/src/sites/twitch-twilight/index.js index 9c0e80a4..05c586d0 100644 --- a/src/sites/twitch-twilight/index.js +++ b/src/sites/twitch-twilight/index.js @@ -188,7 +188,8 @@ Twilight.KNOWN_MODULES = { 'chat-types': n => n.b && has(n.b, 'Message') && has(n.b, 'RoomMods'), 'gql-printer': n => n !== window && n.print, mousetrap: n => n.bindGlobal && n.unbind && n.handleKey, - 'algolia-search': n => n.a && n.a.prototype && n.a.prototype.queryTopResults && n.a.prototype.queryForType + 'algolia-search': n => n.a && n.a.prototype && n.a.prototype.queryTopResults && n.a.prototype.queryForType, + highlightstack: n => n.b && has(n.b, '_calculateChangedBits') && n.c && has(n.c, '_calculateChangedBits') } diff --git a/src/sites/twitch-twilight/modules/chat/emote_menu.jsx b/src/sites/twitch-twilight/modules/chat/emote_menu.jsx index 9bb262a1..68ae1eea 100644 --- a/src/sites/twitch-twilight/modules/chat/emote_menu.jsx +++ b/src/sites/twitch-twilight/modules/chat/emote_menu.jsx @@ -316,7 +316,7 @@ export default class EmoteMenu extends Module { channel_id={this.props.channelOwnerID} loading={this.state.gqlLoading} error={this.state.gqlError} - onClickEmote={this.props.onClickEmote} + onClickToken={this.props.onClickToken} /> ) } @@ -520,7 +520,7 @@ export default class EmoteMenu extends Module { if ( t.emotes.handleClick(event) ) return; - this.props.onClickEmote(event.currentTarget.dataset.name) + this.props.onClickToken(event.currentTarget.dataset.name) } clickHeading() { @@ -1835,7 +1835,7 @@ export default class EmoteMenu extends Module { key: data.key, data, filtered: this.state.filtered, - onClickEmote: this.props.onClickEmote, + onClickToken: this.props.onClickToken, startObserving: this.startObserving, stopObserving: this.stopObserving } diff --git a/src/sites/twitch-twilight/modules/chat/index.js b/src/sites/twitch-twilight/modules/chat/index.js index d23e3abc..432eadd6 100644 --- a/src/sites/twitch-twilight/modules/chat/index.js +++ b/src/sites/twitch-twilight/modules/chat/index.js @@ -621,7 +621,9 @@ export default class ChatHook extends Module { onEnable() { this.on('site.web_munch:loaded', this.grabTypes); + this.on('site.web_munch:loaded', this.defineClasses); this.grabTypes(); + this.defineClasses(); this.chat.context.on('changed:chat.points.show-callouts', () => { this.InlineCallout.forceUpdate(); @@ -974,8 +976,29 @@ export default class ChatHook extends Module { this.ChatContainer.ready((cls, instances) => { const t = this, + old_render = cls.prototype.render, old_catch = cls.prototype.componentDidCatch; + cls.prototype.render = function() { + //try { + if ( t.CommunityStackHandler ) { + const React = t.web_munch.getModule('react'), + out = old_render.call(this), + thing = out?.props?.children?.props?.children; + + if ( React && Array.isArray(thing) ) + thing.push(React.createElement(t.CommunityStackHandler)); + + return out; + } + + /*} catch(err) { + // No op + }*/ + + return old_render.call(this); + } + // Try catching errors. With any luck, maybe we can // recover from the error when we re-build? cls.prototype.componentDidCatch = function(err, info) { @@ -1006,6 +1029,32 @@ export default class ChatHook extends Module { } + defineClasses() { + if ( this.CommunityStackHandler ) + return true; + + const t = this, + React = this.web_munch.getModule('react'), + Stack = this.web_munch.getModule('highlightstack'), + createElement = React && React.createElement; + + if ( ! createElement || ! Stack || ! Stack.b ) + return false; + + this.CommunityStackHandler = function() { + const stack = React.useContext(Stack.b), + dispatch = React.useContext(Stack.c); + + t.community_stack = stack; + t.community_dispatch = dispatch; + + return null; + } + + this.ChatContainer.forceUpdate(); + } + + updatePinnedCallouts() { for(const inst of this.PinnedCallout.instances) this.onPinnedCallout(inst);