From 2e7767ed10c7f63d8fec101afed0bff6113a43a9 Mon Sep 17 00:00:00 2001 From: Michal Orlik Date: Tue, 3 Apr 2018 17:52:07 +0200 Subject: [PATCH] lib/message: Fix refresh of custom_variable widget --- libs/message.js | 3 ++- libs/widgets/custom_variables.js | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/message.js b/libs/message.js index 6a13e972048..28b13f9448b 100644 --- a/libs/message.js +++ b/libs/message.js @@ -101,7 +101,8 @@ class Message { let msg = global.commons.prepare('filters.setVariable', { value: attr.param, variable: variable }) global.commons.sendMessage(msg, { username: attr.sender, quiet: _.get(attr, 'quiet', false) }) - global.widgets.custom_variables.io.emit('refresh') // send update to widget + if (require('cluster').isWorker) process.send({ type: 'widget_custom_variables', emit: 'refresh' }) + else global.widgets.custom_variables.io.emit('refresh') // send update to widget global.twitch.setTitleAndGame(global.twitch, null) // update title return '' diff --git a/libs/widgets/custom_variables.js b/libs/widgets/custom_variables.js index 60ec2b334ca..0082d73aed6 100644 --- a/libs/widgets/custom_variables.js +++ b/libs/widgets/custom_variables.js @@ -7,6 +7,11 @@ class CustomVariablesWidget { constructor () { global.panel.addWidget('customvariables', 'widget-title-customvariables', 'fas fa-dollar-sign') this.sockets() + + require('cluster').on('message', (worker, message) => { + if (message.type !== 'widget_custom_variables') return + this.io.emit(message.emit) // send update to widget + }) } sockets () {