Skip to content

Commit

Permalink
Fixed the mess I did
Browse files Browse the repository at this point in the history
  • Loading branch information
Nrosa01 committed May 2, 2024
1 parent cbbb0a4 commit 255166a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/stores/simulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const useSimulationStore = defineStore("simulation", () => {

const loadWorkspace = (index) => {
Blockly.Events.disable();
const workspace = mainWorkspace.value;
const workspace = mainWorkspace.value ?? Blockly.getMainWorkspace();
const data = particle_array.value[index]?.blockly_workspace;
if (data) {
Blockly.serialization.workspaces.load(data, workspace);
Expand All @@ -100,14 +100,14 @@ export const useSimulationStore = defineStore("simulation", () => {
}

const regenerateCode = () => {
const ws = mainWorkspace.value;
const ws = mainWorkspace.value ?? Blockly.getMainWorkspace();
const particle_base = ws.getBlocksByType("particle_base")[0];
generated_code.value = jsonGenerator.blockToCode(particle_base);
particle_array.value[selected_particle.value].update_data(JSON.parse(generated_code.value));
}

const saveWorkspace = (index) => {
const json = Blockly.serialization.workspaces.save(mainWorkspace.value);
const json = Blockly.serialization.workspaces.save(mainWorkspace.value ?? Blockly.getMainWorkspace());
particle_array.value[index].blockly_workspace = json;
}

Expand Down Expand Up @@ -141,7 +141,6 @@ export const useSimulationStore = defineStore("simulation", () => {
debug,
canvas_size,
particle_array_length,
mainWorkspace,
addParticle,
removeParticle,
removeSelectedParticle,
Expand Down

0 comments on commit 255166a

Please sign in to comment.