From a35387abcf629ac91fc3c9988fcce35b07f7e29e Mon Sep 17 00:00:00 2001 From: SirStendec Date: Fri, 19 Nov 2021 17:12:17 -0500 Subject: [PATCH] 4.31.1 * Fixed: Infinite loop bug with the `` Vue component. * Fixed: Bug with the method that calculates the chat input height causing chat input to disappear completely. * Changed: When an add-on fails to enable, a slightly better message will be logged to console. --- package.json | 2 +- src/addons.js | 10 ++++- .../twitch-twilight/modules/chat/input.jsx | 37 +++++++++++-------- .../css_tweaks/styles/hide-chat-identity.scss | 7 +++- src/std-components/markdown.vue | 28 ++++++++++---- 5 files changed, 55 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index 68ed34f6..656e20e7 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "frankerfacez", "author": "Dan Salvato LLC", - "version": "4.31.0", + "version": "4.31.1", "description": "FrankerFaceZ is a Twitch enhancement suite.", "private": true, "license": "Apache-2.0", diff --git a/src/addons.js b/src/addons.js index cb5b8002..22a3d41a 100644 --- a/src/addons.js +++ b/src/addons.js @@ -85,7 +85,10 @@ export default class AddonManager extends Module { // main script's execution. for(const id of this.enabled_addons) if ( this.hasAddon(id) && this.doesAddonTarget(id) ) - this._enableAddon(id); + this._enableAddon(id).catch(err => { + this.log.error(`An error occured while enabling the add-on "${id}":` , err); + this.log.capture(err); + }); this.emit(':ready'); }); @@ -353,7 +356,10 @@ export default class AddonManager extends Module { // Actually load it. if ( this.doesAddonTarget(id) ) - this._enableAddon(id); + this._enableAddon(id).catch(err => { + this.log.error(`An error occured while enabling the add-on "${id}":` , err); + this.log.capture(err); + }); } async disableAddon(id, save = true) { diff --git a/src/sites/twitch-twilight/modules/chat/input.jsx b/src/sites/twitch-twilight/modules/chat/input.jsx index 9fa95105..ff2540cf 100644 --- a/src/sites/twitch-twilight/modules/chat/input.jsx +++ b/src/sites/twitch-twilight/modules/chat/input.jsx @@ -298,26 +298,31 @@ export default class Input extends Module { const t = this; const originalOnKeyDown = inst.onKeyDown, - originalOnMessageSend = inst.onMessageSend; - //old_resize = inst.resizeInput; + originalOnMessageSend = inst.onMessageSend, + old_resize = inst.resizeInput; - inst.resizeInput = function(msg) { - if ( msg ) { - if ( inst.chatInputRef ) { - const style = getComputedStyle(inst.chatInputRef), - height = style && parseFloat(style.lineHeight || 18) || 18, - t = height * 1 + 20, - i = Math.ceil((inst.chatInputRef.scrollHeight - t) / height), - a = Math.min(1 + i, 4); + inst.resizeInput = function(msg, ...args) { + try { + if ( msg ) { + if ( inst.chatInputRef instanceof Element ) { + const style = getComputedStyle(inst.chatInputRef), + height = style && parseFloat(style.lineHeight || 18) || 18, + t = height * 1 + 20, + i = Math.ceil((inst.chatInputRef.scrollHeight - t) / height), + a = Math.min(1 + i, 4); + inst.setState({ + numInputRows: a + }); + } + } else inst.setState({ - numInputRows: a + numInputRows: 1 }); - } - } else - inst.setState({ - numInputRows: 1 - }); + } catch (err) { + t.log.error('Error in resizeInput', err); + return old_resize.call(this, msg, ...args); + } } inst.messageHistory = []; diff --git a/src/sites/twitch-twilight/modules/css_tweaks/styles/hide-chat-identity.scss b/src/sites/twitch-twilight/modules/css_tweaks/styles/hide-chat-identity.scss index 54633d11..d48a5e64 100644 --- a/src/sites/twitch-twilight/modules/css_tweaks/styles/hide-chat-identity.scss +++ b/src/sites/twitch-twilight/modules/css_tweaks/styles/hide-chat-identity.scss @@ -8,6 +8,9 @@ left: 0; } -.chat-input__textarea .tw-textarea { - padding-left: 1rem !important; +.chat-input__textarea { + .chat-wysiwyg-input__editor, + .tw-textarea { + padding-left: 1rem !important; + } } \ No newline at end of file diff --git a/src/std-components/markdown.vue b/src/std-components/markdown.vue index 0edf1d5a..509bfda6 100644 --- a/src/std-components/markdown.vue +++ b/src/std-components/markdown.vue @@ -14,22 +14,34 @@ export default { data() { return { - md: getMD() + output: '' } }, - computed: { - output() { - if ( ! this.md ) - return ''; - - return this.md.render(this.source); + watch: { + source() { + this.rebuild(); } }, created() { + this.md = getMD(); if ( ! this.md ) - awaitMD().then(md => this.md = md); + awaitMD().then(md => { + this.md = md; + this.rebuild(); + }); + else + this.rebuild(); + }, + + methods: { + rebuild() { + if ( ! this.md ) + this.output = ''; + else + this.output = this.md.render(this.source); + } } }