Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
logging-scratch-gui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Goessmann
logging-scratch-gui
Commits
b07c6451
Commit
b07c6451
authored
5 years ago
by
Paul Kaplan
Browse files
Options
Downloads
Patches
Plain Diff
Fix saving after recording a sound
parent
69b7eef7
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib/vm-listener-hoc.jsx
+11
-7
11 additions, 7 deletions
src/lib/vm-listener-hoc.jsx
test/unit/util/vm-listener-hoc.test.jsx
+42
-0
42 additions, 0 deletions
test/unit/util/vm-listener-hoc.test.jsx
with
53 additions
and
7 deletions
src/lib/vm-listener-hoc.jsx
+
11
−
7
View file @
b07c6451
...
...
@@ -60,9 +60,9 @@ const vmListenerHOC = function (WrappedComponent) {
this
.
props
.
vm
.
postIOData
(
'
userData
'
,
{
username
:
this
.
props
.
username
});
}
// Re-request a targets update when the should
Emit
Update state changes to true
// Re-request a targets update when the shouldUpdate
Targets
state changes to true
// i.e. when the editor transitions out of fullscreen/player only modes
if
(
this
.
props
.
should
Emit
Updates
&&
!
prevProps
.
should
Emit
Updates
)
{
if
(
this
.
props
.
shouldUpdate
Target
s
&&
!
prevProps
.
shouldUpdate
Target
s
)
{
this
.
props
.
vm
.
emitTargetsUpdate
(
false
/* Emit the event, but do not trigger project change */
);
}
}
...
...
@@ -74,12 +74,12 @@ const vmListenerHOC = function (WrappedComponent) {
}
}
handleProjectChanged
()
{
if
(
this
.
props
.
should
Emit
Update
s
&&
!
this
.
props
.
projectChanged
)
{
if
(
this
.
props
.
shouldUpdate
ProjectChanged
&&
!
this
.
props
.
projectChanged
)
{
this
.
props
.
onProjectChanged
();
}
}
handleTargetsUpdate
(
data
)
{
if
(
this
.
props
.
should
Emit
Updates
)
{
if
(
this
.
props
.
shouldUpdate
Target
s
)
{
this
.
props
.
onTargetsUpdate
(
data
);
}
}
...
...
@@ -118,7 +118,8 @@ const vmListenerHOC = function (WrappedComponent) {
/* eslint-disable no-unused-vars */
attachKeyboardEvents
,
projectChanged
,
shouldEmitUpdates
,
shouldUpdateTargets
,
shouldUpdateProjectChanged
,
onBlockDragUpdate
,
onGreenFlag
,
onKeyDown
,
...
...
@@ -158,7 +159,8 @@ const vmListenerHOC = function (WrappedComponent) {
onTurboModeOff
:
PropTypes
.
func
.
isRequired
,
onTurboModeOn
:
PropTypes
.
func
.
isRequired
,
projectChanged
:
PropTypes
.
bool
,
shouldEmitUpdates
:
PropTypes
.
bool
,
shouldUpdateTargets
:
PropTypes
.
bool
,
shouldUpdateProjectChanged
:
PropTypes
.
bool
,
username
:
PropTypes
.
string
,
vm
:
PropTypes
.
instanceOf
(
VM
).
isRequired
};
...
...
@@ -170,8 +172,10 @@ const vmListenerHOC = function (WrappedComponent) {
projectChanged
:
state
.
scratchGui
.
projectChanged
,
// Do not emit target or project updates in fullscreen or player only mode
// or when recording sounds (it leads to garbled recordings on low-power machines)
should
Emit
Updates
:
!
state
.
scratchGui
.
mode
.
isFullScreen
&&
!
state
.
scratchGui
.
mode
.
isPlayerOnly
&&
shouldUpdate
Target
s
:
!
state
.
scratchGui
.
mode
.
isFullScreen
&&
!
state
.
scratchGui
.
mode
.
isPlayerOnly
&&
!
state
.
scratchGui
.
modals
.
soundRecorder
,
// Do not update the projectChanged state in fullscreen or player only mode
shouldUpdateProjectChanged
:
!
state
.
scratchGui
.
mode
.
isFullScreen
&&
!
state
.
scratchGui
.
mode
.
isPlayerOnly
,
vm
:
state
.
scratchGui
.
vm
,
username
:
state
.
session
&&
state
.
session
.
session
&&
state
.
session
.
session
.
user
?
state
.
session
.
session
.
user
.
username
:
''
...
...
This diff is collapsed.
Click to expand it.
test/unit/util/vm-listener-hoc.test.jsx
+
42
−
0
View file @
b07c6451
...
...
@@ -91,4 +91,46 @@ describe('VMListenerHOC', () => {
const
actions
=
store
.
getActions
();
expect
(
actions
.
length
).
toEqual
(
0
);
});
test
(
'
PROJECT_CHANGED does 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
}
/>
);
vm
.
emit
(
'
PROJECT_CHANGED
'
);
const
actions
=
store
.
getActions
();
expect
(
actions
.
length
).
toEqual
(
1
);
});
test
(
'
PROJECT_CHANGED does not dispatch if in fullscreen mode
'
,
()
=>
{
const
Component
=
()
=>
(<
div
/>);
const
WrappedComponent
=
vmListenerHOC
(
Component
);
store
=
mockStore
({
scratchGui
:
{
mode
:
{
isFullScreen
:
true
},
modals
:
{
soundRecorder
:
true
},
vm
:
vm
}
});
mount
(
<
WrappedComponent
store
=
{
store
}
vm
=
{
vm
}
/>
);
vm
.
emit
(
'
PROJECT_CHANGED
'
);
const
actions
=
store
.
getActions
();
expect
(
actions
.
length
).
toEqual
(
0
);
});
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment