diff --git a/src/app/effects/app.effects.ts b/src/app/effects/app.effects.ts
index c500194a..046ce670 100644
--- a/src/app/effects/app.effects.ts
+++ b/src/app/effects/app.effects.ts
@@ -9,8 +9,6 @@ import {MatDialog} from "@angular/material/dialog";
import {ChangeLogDialog} from "../modules/core/dialogs/change-log/change-log.dialog";
import showdown from "showdown";
import {WorkspaceService} from "../services/workspace.service";
-import * as Blockly from "blockly/core";
-import {VariableDialog} from "../modules/core/dialogs/variable/variable.dialog";
@Injectable({
providedIn: 'root',
@@ -38,9 +36,9 @@ export class AppEffects {
.pipe(filter(isToggled => !!isToggled), withLatestFrom(this.appState.codeEditor$))
.subscribe(([, codeEditorType]) => {
if (codeEditorType == CodeEditorType.Beginner) {
- this.appState.setSelectedCodeEditor(CodeEditorType.CPP);
+ this.appState.selectedCodeEditor = CodeEditorType.CPP;
} else if (codeEditorType == CodeEditorType.CPP) {
- this.appState.setSelectedCodeEditor(CodeEditorType.Beginner);
+ this.appState.selectedCodeEditor = CodeEditorType.Beginner;
}
});
@@ -61,7 +59,7 @@ export class AppEffects {
default:
break;
}
- this.appState.setIsCodeEditorToggleConfirmed(false);
+ this.appState.isCodeEditorToggleConfirmed = false;
});
@@ -69,7 +67,7 @@ export class AppEffects {
this.appState.releaseInfo$
.pipe(filter(releaseInfo => !!releaseInfo))
.subscribe(releaseInfo => {
- const releaseVersion = this.appState.getReleaseVersion();
+ const releaseVersion = this.appState.releaseVersion;
if (!releaseVersion) {
return;
}
@@ -128,23 +126,6 @@ export class AppEffects {
}
})
- this.appState.isDesktop$
- .pipe(filter(isDesktop => !!isDesktop))
- .subscribe(() => {
- try {
- Blockly.dialog.setPrompt((msg, defaultValue, callback) => {
- this.dialog.open(VariableDialog, {
- width: '400px',
- data: { name: defaultValue }
- }).afterClosed().subscribe(result => {
- callback(result);
- });
- });
- } catch (e) {
- console.log(e);
- throw e;
- }
- });
}
diff --git a/src/app/effects/blockly-editor.effects.ts b/src/app/effects/blockly-editor.effects.ts
index 1e104df7..9b0a1cd5 100644
--- a/src/app/effects/blockly-editor.effects.ts
+++ b/src/app/effects/blockly-editor.effects.ts
@@ -62,7 +62,7 @@ export class BlocklyEditorEffects {
.pipe(withLatestFrom(this.blocklyState.workspaceJSON$, this.appState.selectedRobotType$))
.subscribe(([, workspaceXml]) => {
this.workspaceService.saveWorkspaceTemp(workspaceXml).then(() => {});
- this.localStorage.store("changedLanguage", this.appState.getSelectedRobotType().id);
+ this.localStorage.store("changedLanguage", this.appState.selectedRobotType.id);
});
// When all prerequisites are there, Create a new workspace and open the codeview if needed
@@ -75,7 +75,7 @@ export class BlocklyEditorEffects {
this.getXmlContent('./assets/blockly/leaphy-start.xml')
))
.subscribe(([[[element, config], robotType], baseToolboxXml, leaphyToolboxXml, startWorkspaceXml]) => {
- const leaphyBlocks = getBlocks(this.appState.getSelectedRobotType().id);
+ const leaphyBlocks = getBlocks(this.appState.selectedRobotType.id);
Blockly.defineBlocksWithJsonArray(leaphyBlocks.block)
config.theme = Blockly.Theme.defineTheme('leaphy', {
'blockStyles': THEME.defaultBlockStyles,
@@ -92,21 +92,21 @@ export class BlocklyEditorEffects {
toolbox.getFlyout().autoClose = false;
const xml = Blockly.utils.xml.textToDom(startWorkspaceXml);
Blockly.Xml.domToWorkspace(xml, workspace);
- this.blocklyState.setWorkspace(workspace);
- this.blocklyState.setToolboxXml(toolboxXmlString);
- if (this.appState.getCurrentEditor() == CodeEditorType.Beginner) {
+ this.blocklyState.workspace = workspace;
+ this.blocklyState.toolboxXml = toolboxXmlString;
+ if (this.appState.currentEditor == CodeEditorType.Beginner) {
this.workspaceService.restoreWorkspaceTemp().then(() => {});
}
toolbox.selectItemByPosition(0);
toolbox.refreshTheme();
- setTimeout(() => this.blocklyState.setIsSideNavOpen(robotType.features.showCodeOnStart), 200);
+ setTimeout(() => this.blocklyState.isSideNavOpen = robotType.features.showCodeOnStart, 200);
});
// When a new project is started, reset the blockly code
this.appState.selectedRobotType$
.pipe(filter(robotType => !robotType))
- .subscribe(() => this.codeEditorState.setCode(''))
+ .subscribe(() => this.codeEditorState.code = '')
// When the robot selection changes, set the toolbox and initialWorkspace
this.appState.selectedRobotType$
@@ -119,7 +119,7 @@ export class BlocklyEditorEffects {
))
.subscribe(([[robotType, workspace], baseToolboxXml, leaphyToolboxXml, startWorkspaceXml]) => {
const toolboxXmlString = this.loadToolBox(baseToolboxXml, leaphyToolboxXml, robotType);
- this.blocklyState.setToolboxXml(toolboxXmlString);
+ this.blocklyState.toolboxXml = toolboxXmlString;
workspace.clear();
const xml = Blockly.utils.xml.textToDom(startWorkspaceXml);
@@ -139,8 +139,8 @@ export class BlocklyEditorEffects {
workspace.clearUndo();
workspace.addChangeListener(Blockly.Events.disableOrphans);
workspace.addChangeListener(async () => {
- this.codeEditorState.setCode(arduino.workspaceToCode(workspace, this.appState.getSelectedRobotType().id));
- this.blocklyState.setWorkspaceJSON(JSON.stringify(Blockly.serialization.workspaces.save(workspace)));
+ this.codeEditorState.code = arduino.workspaceToCode(workspace, this.appState.selectedRobotType.id);
+ this.blocklyState.workspaceJSON = JSON.stringify(Blockly.serialization.workspaces.save(workspace));
});
});
@@ -158,21 +158,14 @@ export class BlocklyEditorEffects {
filter(([previous, current]) => (current === CodeEditorType.CPP || current === CodeEditorType.Python ) && current !== previous)
)
.subscribe(() => {
- this.blocklyState.setIsSideNavOpen(false);
- });
-
- // Toggle the isSideNavOpen state
- this.blocklyState.isSideNavOpenToggled$
- .pipe(filter(isToggled => !!isToggled), withLatestFrom(this.blocklyState.isSideNavOpen$))
- .subscribe(([, isSideNavOpen]) => {
- this.blocklyState.setIsSideNavOpen(!isSideNavOpen);
+ this.blocklyState.isSideNavOpen = false;
});
// Toggle the isSoundOn state
this.blocklyState.isSoundToggled$
.pipe(filter(isToggled => !!isToggled), withLatestFrom(this.blocklyState.isSoundOn$))
.subscribe(([, isSoundOn]) => {
- this.blocklyState.setIsSoundOn(!isSoundOn);
+ this.blocklyState.isSoundOn = !isSoundOn;
});
// When the sound is turned on off, update the Blockly function
@@ -181,7 +174,7 @@ export class BlocklyEditorEffects {
.subscribe(([isSoundOn, basePlay]) => {
if (!basePlay) {
basePlay = Blockly.WorkspaceAudio.prototype.play;
- this.blocklyState.setPlaySoundFunction(basePlay);
+ this.blocklyState.playSoundFunction = basePlay;
}
Blockly.WorkspaceAudio.prototype.play = function (name, opt_volume) {
if (isSoundOn) {
@@ -192,7 +185,7 @@ export class BlocklyEditorEffects {
// When the code editor is changed, clear the projectFilePath
this.appState.codeEditor$
- .subscribe(() => this.blocklyState.setProjectFileHandle(null));
+ .subscribe(() => this.blocklyState.projectFileHandle = null);
}
private parseCategory(root: Document, category: HTMLElement, robotType: RobotType,) : HTMLElement {
diff --git a/src/app/effects/code-editor.effects.ts b/src/app/effects/code-editor.effects.ts
index 092e5d6e..fee2576d 100644
--- a/src/app/effects/code-editor.effects.ts
+++ b/src/app/effects/code-editor.effects.ts
@@ -19,9 +19,9 @@ export class CodeEditorEffects {
this.appState.codeEditor$
.subscribe(codeEditor => {
if (codeEditor == CodeEditorType.Python) {
- this.codeEditorState.setCode(this.codeEditorState.pythonProgram);
- } else if (codeEditor == CodeEditorType.CPP && this.appState.getSelectedRobotType() == genericRobotType) {
- this.codeEditorState.setCode(this.codeEditorState.originalProgram);
+ this.codeEditorState.code = `from leaphymicropython.utils.pins import set_pwm`;
+ } else if (codeEditor == CodeEditorType.CPP && this.appState.selectedRobotType == genericRobotType) {
+ this.codeEditorState.code = this.codeEditorState.originalProgram;
}
});
}
diff --git a/src/app/effects/dialog.effects.ts b/src/app/effects/dialog.effects.ts
index 1500b802..903b52b9 100644
--- a/src/app/effects/dialog.effects.ts
+++ b/src/app/effects/dialog.effects.ts
@@ -45,14 +45,14 @@ export class DialogEffects {
// If the isSerialOutputWindowOpen is set to true open the dialog
this.dialogState.isSerialOutputWindowOpen$
.subscribe(() => {
- if (this.dialogState.getIsSerialOutputWindowOpen() !== true)
+ if (this.dialogState.isSerialOutputWindowOpen !== true)
return;
this.dialog.open(SerialOutputComponent, {
width: "800px",
disableClose: true,
hasBackdrop: false,
}).afterClosed().subscribe(() => {
- this.dialogState.setIsSerialOutputWindowOpen(false);
+ this.dialogState.isSerialOutputWindowOpen = false;
});
});
@@ -60,12 +60,12 @@ export class DialogEffects {
// If the isLibraryManagerWindowOpen is set to true open the dialog
this.dialogState.isLibraryManagerWindowOpen$
.subscribe(() => {
- if (this.dialogState.getIsLibraryManagerWindowOpen() !== true)
+ if (this.dialogState.isLibraryManagerWindowOpen !== true)
return;
this.dialog.open(LibraryManagerComponent, {
disableClose: true,
}).afterClosed().subscribe(() => {
- this.dialogState.setIsLibraryManagerWindowOpen(false);
+ this.dialogState.isLibraryManagerWindowOpen = false;
});
});
diff --git a/src/app/effects/robot.wired.effects.ts b/src/app/effects/robot.wired.effects.ts
index f0f91e92..9ea48705 100644
--- a/src/app/effects/robot.wired.effects.ts
+++ b/src/app/effects/robot.wired.effects.ts
@@ -25,7 +25,7 @@ export class RobotWiredEffects {
this.dialogState.isSerialOutputListening$
.pipe(filter(isListening => !!isListening))
.subscribe(async () => {
- if (this.robotWiredState.getPythonDeviceConnected())
+ if (this.robotWiredState.pythonDeviceConnected)
return;
const robotWiredState = this.robotWiredState;
@@ -38,8 +38,7 @@ export class RobotWiredEffects {
const date = new Date();
function makeString (chunkedStr: string) {
- const serialData = { time: date, data: chunkedStr };
- robotWiredState.setIncomingSerialData(serialData);
+ robotWiredState.incomingSerialData = { time: date, data: chunkedStr };
}
let i = this.logBuffer.indexOf("\n");
diff --git a/src/app/modules/blockly-editor/components/leaphy-blockly/leaphy-blockly.component.ts b/src/app/modules/blockly-editor/components/leaphy-blockly/leaphy-blockly.component.ts
index b7ff8eae..21217887 100644
--- a/src/app/modules/blockly-editor/components/leaphy-blockly/leaphy-blockly.component.ts
+++ b/src/app/modules/blockly-editor/components/leaphy-blockly/leaphy-blockly.component.ts
@@ -55,7 +55,7 @@ export class LeaphyBlocklyComponent implements AfterViewInit {
}
ngAfterViewInit() {
- this.blocklyState.setBlocklyElement(this.blockContent.nativeElement);
+ this.blocklyState.blocklyElement = this.blockContent.nativeElement;
this.blocklyState.workspace$.subscribe(workspace => {
this.workspace = workspace
workspace.addChangeListener((event: any) => {
diff --git a/src/app/modules/code-editor-cpp/code-editor-cpp.page.html b/src/app/modules/code-editor-cpp/code-editor-cpp.page.html
index cf8c6c94..44bf9ca6 100644
--- a/src/app/modules/code-editor-cpp/code-editor-cpp.page.html
+++ b/src/app/modules/code-editor-cpp/code-editor-cpp.page.html
@@ -3,7 +3,7 @@
class="monaco-editor"
[options]="editorOptions"
[ngModel]="codeEditorState.code$ | async"
- (ngModelChange)="codeEditorState.setCode($event)"
+ (ngModelChange)="codeEditorState.code = $event"
/>
- {{(appState.releaseVersion$ | async)}} + {{(appState.releaseVersion)}}