Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

Commit

Permalink
chore: blocks cleanup (#244)
Browse files Browse the repository at this point in the history
* chore: blocks cleanup

* chore: prettier

* chore: prettier

* chore: bump blocks version
  • Loading branch information
koen1711 authored Apr 22, 2024
1 parent 3362931 commit a499d96
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@fortawesome/fontawesome-free": "^6.1.1",
"@leaphy-robotics/avrdude-webassembly": "^1.6.1",
"@leaphy-robotics/dfu-util-wasm": "1.0.2",
"@leaphy-robotics/leaphy-blocks": "2.0.3",
"@leaphy-robotics/leaphy-blocks": "^2.1.0",
"@leaphy-robotics/picotool-wasm": "1.0.2",
"@leaphy-robotics/webusb-ftdi": "^1.0.0",
"@ngx-translate/core": "^14.0.0",
Expand Down
14 changes: 10 additions & 4 deletions src/app/effects/blockly-editor.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
translations,
arduino,
getBlocks,
constantBlocks,
} from "@leaphy-robotics/leaphy-blocks";
import { LeaphyCategory } from "../services/toolbox/category";
import { LeaphyToolbox } from "../services/toolbox/toolbox";
Expand All @@ -30,6 +31,8 @@ import { LocalStorageService } from "../services/localstorage.service";

// Defines the effects on the Blockly Editor that different state changes have
export class BlocklyEditorEffects {
private firstRun = true;

constructor(
private blocklyState: BlocklyEditorState,
private appState: AppState,
Expand Down Expand Up @@ -127,10 +130,13 @@ export class BlocklyEditorEffects {
leaphyToolboxXml,
startWorkspaceXml,
]) => {
const leaphyBlocks = getBlocks(
this.appState.selectedRobotType.id,
);
Blockly.defineBlocksWithJsonArray(leaphyBlocks.block);
let allBlocks = getBlocks(robotType.id).block;
if (this.firstRun) {
this.firstRun = false;
allBlocks = allBlocks.concat(constantBlocks);
}

Blockly.defineBlocksWithJsonArray(allBlocks);
config.theme = Blockly.Theme.defineTheme("leaphy", {
blockStyles: THEME.defaultBlockStyles,
categoryStyles: THEME.categoryStyles,
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1841,10 +1841,10 @@
resolved "https://registry.yarnpkg.com/@leaphy-robotics/dfu-util-wasm/-/dfu-util-wasm-1.0.2.tgz#29afcc01266655e1c7b5da0eeceb0ead48c86fd7"
integrity sha512-lvS+tJFO049b4ERYKX0HcoUtnQv76A1z9sZrAvbs7s3bvdMW0BObKmktZeJ7emcp3lU/+OJWsD2h0EY5rnkiNg==

"@leaphy-robotics/leaphy-blocks@2.0.3":
version "2.0.3"
resolved "https://registry.yarnpkg.com/@leaphy-robotics/leaphy-blocks/-/leaphy-blocks-2.0.3.tgz#ce9965433c59280d45fba0e6245895358ef249f3"
integrity sha512-dLw54rZ0Vr+G81hXyNqjb8VZqraObygSvZ2v5b4XmtuoPsXL7xERvPQcSLdRG2c1u+7iVSFOq/ZNvnXWP8/yqw==
"@leaphy-robotics/leaphy-blocks@^2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@leaphy-robotics/leaphy-blocks/-/leaphy-blocks-2.1.0.tgz#9f24ac65322634e808f6dd1ff74e1e0553ab1965"
integrity sha512-u9AlHl8I8njzqM+/yG39sWgeqFHlVuPXQK59uFdyStsSBk9IpF+e7Ogo13WdXV+ORB831NvyNlSOKNZQEFY/ag==
dependencies:
blockly "^10.4.3"

Expand Down

0 comments on commit a499d96

Please sign in to comment.