File tree Expand file tree Collapse file tree 3 files changed +10
-6
lines changed
packages/app/src/app/overmind/namespaces Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 99} from '@codesandbox/common/lib/types' ;
1010import { Action , AsyncAction } from 'app/overmind' ;
1111import { withLoadApp , withOwnedSandbox } from 'app/overmind/factories' ;
12- import getItems from 'app/overmind/utils/items' ;
1312import {
1413 addDevToolsTab as addDevToolsTabUtil ,
1514 closeDevToolsTab as closeDevToolsTabUtil ,
@@ -95,10 +94,7 @@ export const sandboxChanged: AsyncAction<{ id: string }> = withLoadApp<{
9594
9695 actions . internal . setCurrentSandbox ( sandbox ) ;
9796
98- const items = getItems ( state ) ;
99- const defaultItem = items . find ( i => i . defaultOpen ) || items [ 0 ] ;
100-
101- state . workspace . openedWorkspaceItem = defaultItem . id ;
97+ actions . workspace . openDefaultItem ( ) ;
10298 } catch ( error ) {
10399 state . editor . notFound = true ;
104100 state . editor . error = error . message ;
Original file line number Diff line number Diff line change @@ -345,7 +345,7 @@ export const forkSandbox: AsyncAction<{
345345 forkedSandbox
346346 ) ;
347347 effects . preview . updateAddressbarUrl ( ) ;
348-
348+ actions . workspace . openDefaultItem ( ) ;
349349 effects . notificationToast . success ( 'Forked sandbox!' ) ;
350350 effects . router . updateSandboxUrl ( forkedSandbox ) ;
351351 } catch ( error ) {
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import { CustomTemplate } from '@codesandbox/common/lib/types';
33import slugify from '@codesandbox/common/lib/utils/slugify' ;
44import { Action , AsyncAction } from 'app/overmind' ;
55import { withOwnedSandbox } from 'app/overmind/factories' ;
6+ import getItems from 'app/overmind/utils/items' ;
67
78export const valueChanged : Action < {
89 field : string ;
@@ -285,3 +286,10 @@ export const addedTemplate: AsyncAction<{
285286 ) ;
286287 }
287288} ;
289+
290+ export const openDefaultItem : Action = ( { state } ) => {
291+ const items = getItems ( state ) ;
292+ const defaultItem = items . find ( i => i . defaultOpen ) || items [ 0 ] ;
293+
294+ state . workspace . openedWorkspaceItem = defaultItem . id ;
295+ } ;
You can’t perform that action at this time.
0 commit comments