Skip to content

Commit

Permalink
Fix lock icon not saving when showing and hiding
Browse files Browse the repository at this point in the history
  • Loading branch information
AshimeeAlt committed Sep 20, 2024
1 parent 9251dc4 commit 5a45ba8
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/components/monitor-list/monitor-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const MonitorList = props => (
width={monitorData.width}
x={monitorData.x}
y={monitorData.y}
locked={monitorData.locked}
onDragEnd={props.onMonitorChange}
/>
))}
Expand Down
8 changes: 5 additions & 3 deletions src/components/monitor/list-monitor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,14 @@ ListMonitor.propTypes = {
PropTypes.number
]))
]),
width: PropTypes.number
width: PropTypes.number,
locked: PropTypes.bool
};

ListMonitor.defaultProps = {
width: 110,
height: 200
height: 200,
locked: false
};

export default ListMonitor;
export default ListMonitor;
8 changes: 6 additions & 2 deletions src/containers/list-monitor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ListMonitor extends React.Component {
this.state = {
activeIndex: null,
activeValue: null,
locked: false,
locked: props.locked || false,
width: props.width || 100,
height: props.height || 200
};
Expand Down Expand Up @@ -131,6 +131,10 @@ class ListMonitor extends React.Component {
this.setState({
locked: list.locked
});
this.props.vm.runtime.requestUpdateMonitor(new Map([
['id', variableId],
['locked', list.locked]
]));
}

handleResizeMouseDown (e) {
Expand Down Expand Up @@ -219,4 +223,4 @@ const mapStateToProps = state => ({
vm: state.scratchGui.vm
});

export default connect(mapStateToProps)(ListMonitor);
export default connect(mapStateToProps)(ListMonitor);
2 changes: 1 addition & 1 deletion src/containers/monitor-list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MonitorList extends React.Component {
});
}
}
handleMonitorChange (id, x, y) { // eslint-disable-line no-unused-vars
handleMonitorChange (id, x, y) { // eslint-disable-line no-unused-variables
this.props.moveMonitorRect(id, x, y);
}
render () {
Expand Down
16 changes: 14 additions & 2 deletions src/containers/monitor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const messages = defineMessages({
class Monitor extends React.Component {
constructor (props) {
super(props);
console.log('Props added', props);
bindAll(this, [
'handleDragEnd',
'handleHide',
Expand All @@ -53,7 +54,8 @@ class Monitor extends React.Component {
'setElement'
]);
this.state = {
sliderPrompt: false
sliderPrompt: false,
locked: false,
};
}
componentDidMount () {
Expand Down Expand Up @@ -205,6 +207,14 @@ class Monitor extends React.Component {
const monitorProps = monitorAdapter(this.props);
const showSliderOption = availableModes(this.props.opcode).indexOf('slider') !== -1;
const isList = this.props.mode === 'list';
/*if (isList && this.props.vm) {
console.log('refreshing');
const target = this.props.targetId ? this.props.vm.runtime.getTargetById(this.props.targetId) : this.props.vm.runtime.getTargetForStage();
if (target) {
const variable = target.variables[this.props.id];
this.state.locked = variable?.locked || false;
}
}*/
return (
<React.Fragment>
{this.state.sliderPrompt && <SliderPrompt
Expand All @@ -227,6 +237,7 @@ class Monitor extends React.Component {
targetId={this.props.targetId}
theme={this.props.theme}
width={this.props.width}
locked={this.props.locked}
onDragEnd={this.handleDragEnd}
onExport={isList ? this.handleExport : null}
onImport={isList ? this.handleImport : null}
Expand Down Expand Up @@ -276,7 +287,8 @@ Monitor.propTypes = {
vm: PropTypes.instanceOf(VM),
width: PropTypes.number,
x: PropTypes.number,
y: PropTypes.number
y: PropTypes.number,
locked: PropTypes.boolean,
};
Monitor.defaultProps = {
theme: Theme.light
Expand Down

0 comments on commit 5a45ba8

Please sign in to comment.