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

Disable target updates while sound recording

parent eb874638
Branches
Tags
No related merge requests found
......@@ -164,7 +164,9 @@ const vmListenerHOC = function (WrappedComponent) {
};
const mapStateToProps = state => ({
// Do not emit target or project updates in fullscreen or player only mode
shouldEmitUpdates: !state.scratchGui.mode.isFullScreen && !state.scratchGui.mode.isPlayerOnly,
// or when recording sounds (it leads to garbled recordings on low-power machines)
shouldEmitUpdates: !state.scratchGui.mode.isFullScreen && !state.scratchGui.mode.isPlayerOnly &&
!state.scratchGui.modals.soundRecorder,
vm: state.scratchGui.vm,
username: state.session && state.session.session && state.session.session.user ?
state.session.session.user.username : ''
......
......@@ -15,6 +15,7 @@ describe('VMListenerHOC', () => {
store = mockStore({
scratchGui: {
mode: {},
modals: {},
vm: vm
}
});
......@@ -49,4 +50,45 @@ describe('VMListenerHOC', () => {
const child = wrapper.find(Component);
expect(child.props().onGreenFlag).toBeUndefined();
});
test('targetsUpdate event from vm triggers targets update action', () => {
const Component = () => (<div />);
const WrappedComponent = vmListenerHOC(Component);
mount(
<WrappedComponent
store={store}
vm={vm}
/>
);
const targetList = [];
const editingTarget = 'id';
vm.emit('targetsUpdate', {targetList, editingTarget});
const actions = store.getActions();
expect(actions[0].type).toEqual('scratch-gui/targets/UPDATE_TARGET_LIST');
expect(actions[0].targets).toEqual(targetList);
expect(actions[0].editingTarget).toEqual(editingTarget);
});
test('targetsUpdate does not dispatch if the sound recorder is visible', () => {
const Component = () => (<div />);
const WrappedComponent = vmListenerHOC(Component);
store = mockStore({
scratchGui: {
mode: {},
modals: {soundRecorder: true},
vm: vm
}
});
mount(
<WrappedComponent
store={store}
vm={vm}
/>
);
const targetList = [];
const editingTarget = 'id';
vm.emit('targetsUpdate', {targetList, editingTarget});
const actions = store.getActions();
expect(actions.length).toEqual(0);
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment