diff --git a/love/package.json b/love/package.json index 1fd086b77..8f033c464 100644 --- a/love/package.json +++ b/love/package.json @@ -15,7 +15,7 @@ "file-saver": "^2.0.1", "howler": "^2.1.3", "html2canvas": "^1.0.0-rc.5", - "lodash": "^4.17.19", + "lodash": "^4.17.21", "lodash.throttle": "^4.1.1", "lodash.debounce": "^4.0.8", "luxon": "^1.23.0", diff --git a/love/src/components/CommandPanel/CommandPanel.container.jsx b/love/src/components/CommandPanel/CommandPanel.container.jsx index 62784c9b0..6baa9d105 100644 --- a/love/src/components/CommandPanel/CommandPanel.container.jsx +++ b/love/src/components/CommandPanel/CommandPanel.container.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { connect } from 'react-redux'; -import { requestSALCommand } from '../../redux/actions/ws'; +import { addGroup, removeGroup, requestSALCommand } from '../../redux/actions/ws'; import { getPermCmdExec, getScriptQueueState } from '../../redux/selectors'; import CommandPanel from './CommandPanel'; @@ -20,6 +20,12 @@ export const schema = { isPrivate: true, default: false, }, + scriptQueueIndex: { + type: 'number', + description: 'Salindex of the ScriptQueue to listen events', + isPrivate: false, + default: 1, + }, }, }; @@ -28,20 +34,27 @@ const CommandPanelContainer = ({ ...props }) => { }; const mapDispatchToProps = (dispatch, ownProps) => { + const subscriptions = [`event-ScriptQueueState-${ownProps.scriptQueueIndex}-stream`]; return { + subscriptions, + subscribeToStreams: () => { + subscriptions.forEach((stream) => dispatch(addGroup(stream))); + }, + unsubscribeToStreams: () => { + subscriptions.forEach((stream) => dispatch(removeGroup(stream))); + }, requestSALCommand: (component, salindex, cmd) => { - return; dispatch(requestSALCommand({ ...cmd, component, salindex })); }, }; }; -const mapStateToProps = (state) => { +const mapStateToProps = (state, ownProps) => { const commandExecutePermission = getPermCmdExec(state); - const queueState = getScriptQueueState(state, 1); + const queueState = getScriptQueueState(state, ownProps.scriptQueueIndex); return { - commandExecutePermission: commandExecutePermission, - queueState: queueState, + commandExecutePermission, + queueState, }; }; diff --git a/love/src/components/CommandPanel/StopAllTSCButton/StopAllTSCButton.jsx b/love/src/components/CommandPanel/StopAllTSCButton/StopAllTSCButton.jsx index db9d2dd33..39b79c285 100644 --- a/love/src/components/CommandPanel/StopAllTSCButton/StopAllTSCButton.jsx +++ b/love/src/components/CommandPanel/StopAllTSCButton/StopAllTSCButton.jsx @@ -15,11 +15,17 @@ export default class StopAllTSCButton extends Component { } render() { + const isAvailable = this.props.commandExecutePermission && this.props.queueState.state !== 'Running'; return (