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
c670d4f1
Commit
c670d4f1
authored
7 years ago
by
Moran T
Committed by
Paul Kaplan
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Remove shouldComponentUpdate from vmListenerHOC, move block drag end
to target pane, which already has all the needed props.
parent
0a741b10
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/containers/target-pane.jsx
+17
-0
17 additions, 0 deletions
src/containers/target-pane.jsx
src/lib/vm-listener-hoc.jsx
+0
-22
0 additions, 22 deletions
src/lib/vm-listener-hoc.jsx
with
17 additions
and
22 deletions
src/containers/target-pane.jsx
+
17
−
0
View file @
c670d4f1
...
...
@@ -10,6 +10,7 @@ import {
}
from
'
../reducers/modals
'
;
import
{
activateTab
,
COSTUMES_TAB_INDEX
}
from
'
../reducers/editor-tab
'
;
import
{
setReceivedBlocks
}
from
'
../reducers/hovered-target
'
;
import
TargetPaneComponent
from
'
../components/target-pane/target-pane.jsx
'
;
import
spriteLibraryContent
from
'
../lib/libraries/sprites.json
'
;
...
...
@@ -18,6 +19,7 @@ class TargetPane extends React.Component {
constructor
(
props
)
{
super
(
props
);
bindAll
(
this
,
[
'
handleBlockDragEnd
'
,
'
handleChangeSpriteDirection
'
,
'
handleChangeSpriteName
'
,
'
handleChangeSpriteSize
'
,
...
...
@@ -31,6 +33,12 @@ class TargetPane extends React.Component {
'
handlePaintSpriteClick
'
]);
}
componentDidMount
()
{
this
.
props
.
vm
.
addListener
(
'
BLOCK_DRAG_END
'
,
this
.
handleBlockDragEnd
);
}
componentWillUnmount
()
{
this
.
props
.
vm
.
removeListener
(
'
BLOCK_DRAG_END
'
,
this
.
handleBlockDragEnd
);
}
handleChangeSpriteDirection
(
direction
)
{
this
.
props
.
vm
.
postSpriteInfo
({
direction
});
}
...
...
@@ -71,6 +79,12 @@ class TargetPane extends React.Component {
});
}
}
handleBlockDragEnd
(
blocks
)
{
if
(
this
.
props
.
hoveredTarget
.
sprite
&&
this
.
props
.
hoveredTarget
.
sprite
!==
this
.
props
.
editingTarget
)
{
this
.
props
.
vm
.
shareBlocksToTarget
(
blocks
,
this
.
props
.
hoveredTarget
.
sprite
);
this
.
props
.
onReceivedBlocks
(
true
);
}
}
render
()
{
const
{
onActivateTab
,
// eslint-disable-line no-unused-vars
...
...
@@ -134,6 +148,9 @@ const mapDispatchToProps = dispatch => ({
},
onActivateTab
:
tabIndex
=>
{
dispatch
(
activateTab
(
tabIndex
));
},
onReceivedBlocks
:
receivedBlocks
=>
{
dispatch
(
setReceivedBlocks
(
receivedBlocks
));
}
});
...
...
This diff is collapsed.
Click to expand it.
src/lib/vm-listener-hoc.jsx
+
0
−
22
View file @
c670d4f1
...
...
@@ -8,7 +8,6 @@ import {connect} from 'react-redux';
import
{
updateEditingTarget
,
updateTargets
}
from
'
../reducers/targets
'
;
import
{
updateBlockDrag
}
from
'
../reducers/block-drag
'
;
import
{
updateMonitors
}
from
'
../reducers/monitors
'
;
import
{
setReceivedBlocks
}
from
'
../reducers/hovered-target
'
;
/*
* Higher Order Component to manage events emitted by the VM
...
...
@@ -20,7 +19,6 @@ const vmListenerHOC = function (WrappedComponent) {
constructor
(
props
)
{
super
(
props
);
bindAll
(
this
,
[
'
handleBlockDragEnd
'
,
'
handleKeyDown
'
,
'
handleKeyUp
'
]);
...
...
@@ -33,8 +31,6 @@ const vmListenerHOC = function (WrappedComponent) {
this
.
props
.
vm
.
on
(
'
targetsUpdate
'
,
this
.
props
.
onTargetsUpdate
);
this
.
props
.
vm
.
on
(
'
MONITORS_UPDATE
'
,
this
.
props
.
onMonitorsUpdate
);
this
.
props
.
vm
.
on
(
'
BLOCK_DRAG_UPDATE
'
,
this
.
props
.
onBlockDragUpdate
);
this
.
props
.
vm
.
on
(
'
BLOCK_DRAG_END
'
,
this
.
handleBlockDragEnd
);
}
componentDidMount
()
{
if
(
this
.
props
.
attachKeyboardEvents
)
{
...
...
@@ -42,21 +38,12 @@ const vmListenerHOC = function (WrappedComponent) {
document
.
addEventListener
(
'
keyup
'
,
this
.
handleKeyUp
);
}
}
shouldComponentUpdate
()
{
return
false
;
}
componentWillUnmount
()
{
if
(
this
.
props
.
attachKeyboardEvents
)
{
document
.
removeEventListener
(
'
keydown
'
,
this
.
handleKeyDown
);
document
.
removeEventListener
(
'
keyup
'
,
this
.
handleKeyUp
);
}
}
handleBlockDragEnd
(
blocks
)
{
if
(
this
.
props
.
hoveredSprite
&&
this
.
props
.
hoveredSprite
!==
this
.
props
.
editingTarget
)
{
this
.
props
.
vm
.
shareBlocksToTarget
(
blocks
,
this
.
props
.
hoveredSprite
);
this
.
props
.
onReceivedBlocks
(
true
);
}
}
handleKeyDown
(
e
)
{
// Don't capture keys intended for Blockly inputs.
if
(
e
.
target
!==
document
&&
e
.
target
!==
document
.
body
)
return
;
...
...
@@ -88,13 +75,10 @@ const vmListenerHOC = function (WrappedComponent) {
const
{
/* eslint-disable no-unused-vars */
attachKeyboardEvents
,
editingTarget
,
hoveredSprite
,
onBlockDragUpdate
,
onKeyDown
,
onKeyUp
,
onMonitorsUpdate
,
onReceivedBlocks
,
onTargetsUpdate
,
/* eslint-enable no-unused-vars */
...
props
...
...
@@ -104,13 +88,10 @@ const vmListenerHOC = function (WrappedComponent) {
}
VMListener
.
propTypes
=
{
attachKeyboardEvents
:
PropTypes
.
bool
,
editingTarget
:
PropTypes
.
string
,
hoveredSprite
:
PropTypes
.
string
,
onBlockDragUpdate
:
PropTypes
.
func
.
isRequired
,
onKeyDown
:
PropTypes
.
func
,
onKeyUp
:
PropTypes
.
func
,
onMonitorsUpdate
:
PropTypes
.
func
.
isRequired
,
onReceivedBlocks
:
PropTypes
.
func
.
isRequired
,
onTargetsUpdate
:
PropTypes
.
func
.
isRequired
,
vm
:
PropTypes
.
instanceOf
(
VM
).
isRequired
};
...
...
@@ -132,9 +113,6 @@ const vmListenerHOC = function (WrappedComponent) {
},
onBlockDragUpdate
:
areBlocksOverGui
=>
{
dispatch
(
updateBlockDrag
(
areBlocksOverGui
));
},
onReceivedBlocks
:
receivedBlocks
=>
{
dispatch
(
setReceivedBlocks
(
receivedBlocks
));
}
});
return
connect
(
...
...
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