Skip to content

Commit c81cdc9

Browse files
committed
Fix live resetting the sandbox on load
1 parent bc2acb7 commit c81cdc9

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

packages/app/src/app/store/modules/editor/getters.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ export function currentModule() {
3030
export function modulesByPath() {
3131
const modulesObject = {};
3232

33+
if (!this.currentSandbox) {
34+
return modulesObject;
35+
}
36+
3337
this.currentSandbox.modules.forEach(m => {
3438
const path = getModulePath(
3539
this.currentSandbox.modules,

packages/app/src/app/store/sequences.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,19 @@ export const setSandbox = [
151151
setupExecutor,
152152
syncFilesToFS,
153153

154-
// Remove the old sandbox because it's stale with the changes the user did on it (for example,
155-
// the user might have changed code of a file and then forked. We didn't revert the code back
156-
// to its old state so if the user opens this sandbox again it shows wrong code)
157-
unset(state`editor.sandboxes.${props`oldId`}`),
154+
// Check because in live oldId === currentId
155+
when(
156+
props`oldId`,
157+
state`editor.currentId`,
158+
(oldId, currentId) => oldId === currentId
159+
),
160+
{
161+
true: [],
162+
// Remove the old sandbox because it's stale with the changes the user did on it (for example,
163+
// the user might have changed code of a file and then forked. We didn't revert the code back
164+
// to its old state so if the user opens this sandbox again it shows wrong code)
165+
false: [unset(state`editor.sandboxes.${props`oldId`}`)],
166+
},
158167
],
159168
},
160169
];

0 commit comments

Comments
 (0)