File tree Expand file tree Collapse file tree 3 files changed +22
-23
lines changed
packages/app/src/app/overmind/effects Expand file tree Collapse file tree 3 files changed +22
-23
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import { client } from 'app/graphql/client';
2323import { LIST_TEMPLATES } from 'app/pages/Dashboard/queries' ;
2424
2525import apiFactory , { Api , ApiConfig } from './apiFactory' ;
26+ import { transformSandbox } from '../utils/sandbox' ;
2627
2728let api : Api ;
2829
@@ -65,16 +66,7 @@ export default {
6566 const sandbox = await api . get < Sandbox > ( `/sandboxes/${ id } ` ) ;
6667
6768 // We need to add client side properties for tracking
68- return {
69- ...sandbox ,
70- modules : sandbox . modules . map ( module => ( {
71- ...module ,
72- savedCode : null ,
73- isNotSynced : false ,
74- errors : [ ] ,
75- corrections : [ ] ,
76- } ) ) ,
77- } ;
69+ return transformSandbox ( sandbox ) ;
7870 } ,
7971 async forkSandbox ( id : string , body ?: unknown ) : Promise < Sandbox > {
8072 const url = id . includes ( '/' )
@@ -83,16 +75,7 @@ export default {
8375
8476 const sandbox = await api . post < Sandbox > ( url , body || { } ) ;
8577
86- return {
87- ...sandbox ,
88- modules : sandbox . modules . map ( module => ( {
89- ...module ,
90- savedCode : null ,
91- isNotSynced : false ,
92- errors : [ ] ,
93- corrections : [ ] ,
94- } ) ) ,
95- } ;
78+ return transformSandbox ( sandbox ) ;
9679 } ,
9780 createModule ( sandboxId : string , module : Module ) : Promise < Module > {
9881 return api . post ( `/sandboxes/${ sandboxId } /modules` , {
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
1212} from '@codesandbox/common/lib/types' ;
1313import { getTextOperation } from '@codesandbox/common/lib/utils/diff' ;
1414import clientsFactory from './clients' ;
15+ import { transformSandbox } from '../utils/sandbox' ;
1516
1617type Options = {
1718 onApplyOperation ( args : { moduleShortid : string ; operation : any } ) : void ;
@@ -107,9 +108,11 @@ export default {
107108 return new Promise ( ( resolve , reject ) => {
108109 channel
109110 . join ( )
110- . receive ( 'ok' , resp =>
111- resolve ( camelizeKeys ( resp ) as JoinChannelResponse )
112- )
111+ . receive ( 'ok' , resp => {
112+ const result = camelizeKeys ( resp ) as JoinChannelResponse ;
113+ result . sandbox = transformSandbox ( result . sandbox ) ;
114+ resolve ( result ) ;
115+ } )
113116 . receive ( 'error' , resp => reject ( camelizeKeys ( resp ) ) ) ;
114117 } ) ;
115118 } ,
Original file line number Diff line number Diff line change 1+ export function transformSandbox ( sandbox : Sandbox ) {
2+ // We need to add client side properties for tracking
3+ return {
4+ ...sandbox ,
5+ modules : sandbox . modules . map ( module => ( {
6+ ...module ,
7+ savedCode : null ,
8+ isNotSynced : false ,
9+ errors : [ ] ,
10+ corrections : [ ] ,
11+ } ) ) ,
12+ } ;
13+ }
You can’t perform that action at this time.
0 commit comments