File tree Expand file tree Collapse file tree 7 files changed +25
-19
lines changed
Expand file tree Collapse file tree 7 files changed +25
-19
lines changed Original file line number Diff line number Diff line change @@ -22,8 +22,8 @@ import {
2222import { client } from 'app/graphql/client' ;
2323import { LIST_TEMPLATES } from 'app/pages/Dashboard/queries' ;
2424
25- import apiFactory , { Api , ApiConfig } from './apiFactory' ;
2625import { transformSandbox } from '../utils/sandbox' ;
26+ import apiFactory , { Api , ApiConfig } from './apiFactory' ;
2727
2828let api : Api ;
2929
Original file line number Diff line number Diff line change 1+ import { Sandbox } from '@codesandbox/common/lib/types' ;
2+
13export function transformSandbox ( sandbox : Sandbox ) {
24 // We need to add client side properties for tracking
35 return {
@@ -8,6 +10,11 @@ export function transformSandbox(sandbox: Sandbox) {
810 isNotSynced : false ,
911 errors : [ ] ,
1012 corrections : [ ] ,
13+ type : 'file' as 'file' ,
14+ } ) ) ,
15+ directories : sandbox . directories . map ( directory => ( {
16+ ...directory ,
17+ type : 'directory' as 'directory' ,
1118 } ) ) ,
1219 } ;
1320}
Original file line number Diff line number Diff line change @@ -187,19 +187,13 @@ export const state: State = {
187187 const pathItem = modulePaths [ path ] ;
188188
189189 if ( pathItem . type === 'file' ) {
190- modulesByPath [ path ] = {
191- ...modulePaths [ path ] ,
192- ...currentSandbox . modules . find (
193- moduleItem => moduleItem . shortid === pathItem . shortid
194- ) ,
195- } ;
190+ modulesByPath [ path ] = currentSandbox . modules . find (
191+ moduleItem => moduleItem . shortid === pathItem . shortid
192+ ) ;
196193 } else {
197- modulesByPath [ path ] = {
198- ...modulePaths [ path ] ,
199- ...currentSandbox . directories . find (
200- moduleItem => moduleItem . shortid === pathItem . shortid
201- ) ,
202- } ;
194+ modulesByPath [ path ] = currentSandbox . directories . find (
195+ moduleItem => moduleItem . shortid === pathItem . shortid
196+ ) ;
203197 }
204198 } ) ;
205199
Original file line number Diff line number Diff line change 1- import { AsyncAction } from 'app/overmind' ;
21import { getModulePath } from '@codesandbox/common/lib/sandbox/modules' ;
32import getDefinition from '@codesandbox/common/lib/templates' ;
4- import denormalize from 'codesandbox-import-utils/lib/utils/files/denormalize' ;
5- import { INormalizedModules } from 'codesandbox-import-util-types' ;
63import { ModuleTab } from '@codesandbox/common/lib/types' ;
7- import { createOptimisticModule } from 'app/overmind/utils/common ' ;
4+ import { AsyncAction } from 'app/overmind' ;
85import { withOwnedSandbox } from 'app/overmind/factories' ;
6+ import { createOptimisticModule } from 'app/overmind/utils/common' ;
7+ import { INormalizedModules } from 'codesandbox-import-util-types' ;
8+ import denormalize from 'codesandbox-import-utils/lib/utils/files/denormalize' ;
9+
910import {
10- resolveModuleWrapped ,
1111 resolveDirectoryWrapped ,
12+ resolveModuleWrapped ,
1213} from '../../utils/resolve-module-wrapped' ;
1314import * as internalActions from './internalActions' ;
1415
@@ -59,6 +60,7 @@ export const directoryCreated: AsyncAction<{
5960 sourceId : state . editor . currentSandbox . sourceId ,
6061 insertedAt : new Date ( ) . toString ( ) ,
6162 updatedAt : new Date ( ) . toString ( ) ,
63+ type : 'directory' as 'directory' ,
6264 } ;
6365
6466 sandbox . directories . push ( optimisticDirectory ) ;
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ export const onInitialize: OnInitialize = (
99 effects . fsSync . initialize ( {
1010 onModulesByPathChange ( cb : ( modulesByPath : any ) => void ) {
1111 overmindInstance . reaction (
12- ( { editor } ) => editor . modulesByPath ,
12+ ( { editor } ) => editor . modulePaths ,
1313 ( { editor } ) => cb ( editor . modulesByPath )
1414 ) ;
1515 } ,
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export function createOptimisticModule(overrides: Partial<Module>) {
2020 isNotSynced : true ,
2121 errors : [ ] ,
2222 corrections : [ ] ,
23+ type : 'file' as 'file' ,
2324 ...overrides ,
2425 } ;
2526}
Original file line number Diff line number Diff line change @@ -58,6 +58,7 @@ export type Module = {
5858 updatedAt : string ;
5959 path ?: string ;
6060 now ?: any ;
61+ type : 'file' ;
6162} ;
6263
6364export type Directory = {
@@ -66,6 +67,7 @@ export type Directory = {
6667 directoryShortid : string | undefined ;
6768 shortid : string ;
6869 sourceId : string ;
70+ type : 'directory' ;
6971} ;
7072
7173export type Template = {
You can’t perform that action at this time.
0 commit comments