File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
packages/app/src/app/store Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ export function currentModule() {
3030export 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 ,
Original file line number Diff line number Diff 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] ;
You can’t perform that action at this time.
0 commit comments