Skip to content
Snippets Groups Projects
Commit 97d3f857 authored by Paul Kaplan's avatar Paul Kaplan
Browse files

Update targets list and editing target at the same time.

Prevent crashes resulting from the editing target not being on the target list.
parent 2a6ac6ff
No related branches found
No related tags found
No related merge requests found
......@@ -98,8 +98,7 @@ const vmListenerHOC = function (WrappedComponent) {
});
const mapDispatchToProps = dispatch => ({
onTargetsUpdate: data => {
dispatch(updateEditingTarget(data.editingTarget));
dispatch(updateTargets(data.targetList));
dispatch(updateTargets(data.targetList, data.editingTarget));
},
onMonitorsUpdate: monitorList => {
dispatch(updateMonitors(monitorList));
......
const UPDATE_EDITING_TARGET = 'scratch-gui/targets/UPDATE_EDITING_TARGET';
const UPDATE_TARGET_LIST = 'scratch-gui/targets/UPDATE_TARGET_LIST';
const initialState = {
......@@ -21,27 +20,18 @@ const reducer = function (state, action) {
{}
),
stage: action.targets
.filter(target => target.isStage)[0] || {}
.filter(target => target.isStage)[0] || {},
editingTarget: action.editingTarget
});
case UPDATE_EDITING_TARGET:
return Object.assign({}, state, {editingTarget: action.target});
default:
return state;
}
};
const updateTargets = function (targetList) {
const updateTargets = function (targetList, editingTarget) {
return {
type: UPDATE_TARGET_LIST,
targets: targetList,
meta: {
throttle: 30
}
};
};
const updateEditingTarget = function (editingTarget) {
return {
type: UPDATE_EDITING_TARGET,
target: editingTarget,
editingTarget: editingTarget,
meta: {
throttle: 30
}
......@@ -49,6 +39,5 @@ const updateEditingTarget = function (editingTarget) {
};
export {
reducer as default,
updateTargets,
updateEditingTarget
updateTargets
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment