From 2142f132f5aaf4031e11c0a253ed023e5a3af2c6 Mon Sep 17 00:00:00 2001 From: SirStendec Date: Tue, 13 Aug 2019 16:22:04 -0400 Subject: [PATCH] 4.9.2 * Added: Option to display Chat Room Actions above chat input, as they used to be positioned before 4.9.1. --- package.json | 2 +- src/modules/chat/actions/index.jsx | 13 +++++++++++-- src/sites/twitch-twilight/modules/chat/input.jsx | 13 +++++++++---- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index a24b207e..e0151cf5 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "frankerfacez", "author": "Dan Salvato LLC", - "version": "4.9.1", + "version": "4.9.2", "description": "FrankerFaceZ is a Twitch enhancement suite.", "license": "Apache-2.0", "scripts": { diff --git a/src/modules/chat/actions/index.jsx b/src/modules/chat/actions/index.jsx index 1bd9a33b..f49bc475 100644 --- a/src/modules/chat/actions/index.jsx +++ b/src/modules/chat/actions/index.jsx @@ -148,6 +148,15 @@ export default class Actions extends Module { } }); + this.settings.add('chat.actions.room-above', { + default: false, + ui: { + path: 'Chat > Actions > Room >> General', + component: 'setting-check-box', + title: 'Display Room Actions above the chat input box.' + } + }); + this.settings.add('chat.actions.rules-as-reasons', { default: true, ui: { @@ -420,7 +429,7 @@ export default class Actions extends Module { } - renderRoom(mod_icons, current_user, current_room, createElement) { + renderRoom(mod_icons, current_user, current_room, is_above, createElement) { const actions = [], chat = this.resolve('site.chat'); @@ -465,7 +474,7 @@ export default class Actions extends Module { const room = current_room && JSON.stringify(current_room); return (
{actions} diff --git a/src/sites/twitch-twilight/modules/chat/input.jsx b/src/sites/twitch-twilight/modules/chat/input.jsx index 600f5e53..1c9bd688 100644 --- a/src/sites/twitch-twilight/modules/chat/input.jsx +++ b/src/sites/twitch-twilight/modules/chat/input.jsx @@ -133,6 +133,7 @@ export default class Input extends Module { async onEnable() { this.chat.context.on('changed:chat.actions.room', () => this.ChatInput.forceUpdate()); + this.chat.context.on('changed:chat.actions.room-above', () => this.ChatInput.forceUpdate()); this.chat.context.on('changed:chat.tab-complete.emotes-without-colon', enabled => { for (const inst of this.EmoteSuggestions.instances) inst.canBeTriggeredByTab = enabled; @@ -155,8 +156,9 @@ export default class Input extends Module { cls.prototype.render = function() { const out = old_render.call(this); try { - const container = findReactFragment(out, n => n.props && n.props.children && n.props.className === 'chat-input__buttons-container'); - if ( ! container ) + const above = t.chat.context.get('chat.actions.room-above'), + container = above ? out : findReactFragment(out, n => n.props && n.props.className === 'chat-input__buttons-container'); + if ( ! container || ! container.props || ! container.props.children ) return out; const props = this.props; @@ -180,8 +182,11 @@ export default class Input extends Module { subsMode: props.subsOnlyMode } - const actions = t.actions.renderRoom(t.chat.context.get('context.chat.showModIcons'), u, r, createElement); - container.props.children.splice(1, 0, actions || null); + const actions = t.actions.renderRoom(t.chat.context.get('context.chat.showModIcons'), u, r, above, createElement); + if ( above ) + container.props.children.unshift(actions || null); + else + container.props.children.splice(1, 0, actions || null); } catch(err) { t.log.error(err);