Skip to content

Commit 67a5e05

Browse files
authored
refactor: fix compatibility with checkboxes and category status indicators (#29)
* refactor: fix compatibility with checkboxes and category status indicators * chore: remove errant logging
1 parent 9bd036b commit 67a5e05

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

src/containers/blocks.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class Blocks extends React.Component {
9494
this.ScratchBlocks.ScratchVariables.setPromptHandler(
9595
this.handlePromptStart
9696
);
97-
this.ScratchBlocks.statusButtonCallback =
97+
this.ScratchBlocks.StatusIndicatorLabel.statusButtonCallback =
9898
this.handleConnectionModalStart;
9999
this.ScratchBlocks.recordSoundCallback = this.handleOpenSoundRecorder;
100100

@@ -110,7 +110,7 @@ class Blocks extends React.Component {
110110
this.props.useCatBlocks
111111
);
112112
this.ScratchBlocks.dialog.setPrompt(this.handlePromptStart);
113-
this.ScratchBlocks.statusButtonCallback =
113+
this.ScratchBlocks.StatusIndicatorLabel.statusButtonCallback =
114114
this.handleConnectionModalStart;
115115
this.ScratchBlocks.recordSoundCallback = this.handleOpenSoundRecorder;
116116

@@ -716,7 +716,7 @@ class Blocks extends React.Component {
716716
this.props.onOpenConnectionModal(extensionId);
717717
}
718718
handleStatusButtonUpdate() {
719-
this.ScratchBlocks.refreshStatusButtons(this.workspace);
719+
this.workspace.getFlyout().refreshStatusButtons();
720720
}
721721
handleOpenSoundRecorder() {
722722
this.props.onOpenSoundRecorder();

src/lib/blocks.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -396,19 +396,20 @@ export default function (vm, useCatBlocks) {
396396
this.jsonInit(json);
397397
};
398398

399-
ScratchBlocks.CheckableContinuousFlyout.prototype.getCheckboxState =
400-
function (blockId) {
401-
const monitoredBlock = vm.runtime.monitorBlocks._blocks[blockId];
402-
return monitoredBlock ? monitoredBlock.isMonitored : false;
403-
};
399+
ScratchBlocks.CheckboxBubble.prototype.isChecked = function (blockId) {
400+
const monitoredBlock = vm.runtime.monitorBlocks._blocks[blockId];
401+
return monitoredBlock ? monitoredBlock.isMonitored : false;
402+
};
403+
404+
ScratchBlocks.StatusIndicatorLabel.prototype.getExtensionState = function (
405+
extensionId
406+
) {
407+
if (vm.getPeripheralIsConnected(extensionId)) {
408+
return ScratchBlocks.StatusButtonState.READY;
409+
}
410+
return ScratchBlocks.StatusButtonState.NOT_READY;
411+
};
404412

405-
// ScratchBlocks.FlyoutExtensionCategoryHeader.getExtensionState = function (extensionId) {
406-
// if (vm.getPeripheralIsConnected(extensionId)) {
407-
// return ScratchBlocks.StatusButtonState.READY;
408-
// }
409-
// return ScratchBlocks.StatusButtonState.NOT_READY;
410-
// };
411-
//
412413
// ScratchBlocks.FieldNote.playNote_ = function (noteNum, extensionId) {
413414
// vm.runtime.emit('PLAY_NOTE', noteNum, extensionId);
414415
// };

0 commit comments

Comments
 (0)