Skip to content

Commit

Permalink
lib/message: Fix refresh of custom_variable widget
Browse files Browse the repository at this point in the history
  • Loading branch information
sogehige committed Apr 3, 2018
1 parent 7930fa7 commit 2e7767e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion libs/message.js
Expand Up @@ -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 ''
Expand Down
5 changes: 5 additions & 0 deletions libs/widgets/custom_variables.js
Expand Up @@ -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 () {
Expand Down

0 comments on commit 2e7767e

Please sign in to comment.