Skip to content

Commit

Permalink
Resolved issue with legacy support overwriting the behavior of button…
Browse files Browse the repository at this point in the history
… blocks
  • Loading branch information
pmalacho-mit committed Nov 27, 2023
1 parent 866f58a commit 3687096
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ export default function legacySupportMixin<T extends MinimalExtensionConstructor
return { menuUpdates, replaceAt: { index, block: legacyBlock } };
});

updates.forEach(({ replaceAt: { index, block } }) => mutableBlocks[index] = block);
updates.forEach(({ replaceAt: { index, block } }) => {
const current = mutableBlocks[index];
mutableBlocks[index] = block;
if (block.blockType === "button") mutableBlocks[index].func = current.func;
});

updates
.map(({ menuUpdates }) => menuUpdates)
Expand Down
9 changes: 2 additions & 7 deletions extensions/src/teachableMachine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import tmPose from '@teachablemachine/pose';
import { create } from '@tensorflow-models/speech-commands';
import { legacyFullSupport, } from "./legacy";

const { legacyExtension, legacyBlock } = legacyFullSupport.for<teachableMachine>();
const { legacyBlock, legacyExtension } = legacyFullSupport.for<teachableMachine>();
const VideoState = {
/** Video turned off. */
OFF: 'off',
Expand All @@ -26,7 +26,6 @@ export default class teachableMachine extends extension({
insetIconURL: "teachable-machine-blocks-small.svg",
tags: ["Dancing with AI", "Made by PRG"]
}) {

lastUpdate: number;
maxConfidence: number;
modelConfidences: {};
Expand Down Expand Up @@ -75,9 +74,6 @@ export default class teachableMachine extends extension({
// Kick off looping the analysis logic.
this._loop();
}


this.runtime.on('OPEN_TEACHABLE_MACHINE', this.openTeachableMachineSite.bind(this));
}

/**
Expand Down Expand Up @@ -317,8 +313,7 @@ export default class teachableMachine extends extension({
* Opens a new tab with the Google Teachable Machine website
*/
@legacyBlock.openTeachableMachine()
openTeachableMachine() {}
openTeachableMachineSite() {
openTeachableMachine() {
window.open('https://teachablemachine.withgoogle.com/train', '_blank');
}

Expand Down

0 comments on commit 3687096

Please sign in to comment.