Skip to content

Commit a284387

Browse files
committed
refactor MoudleEntry to overmind
1 parent f55dc4e commit a284387

File tree

1 file changed

+28
-10
lines changed
  • packages/app/src/app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/DirectoryChildren

1 file changed

+28
-10
lines changed
Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
1-
import { inject, observer } from 'app/componentConnectors';
1+
import { Module, Directory } from '@codesandbox/common/lib/types';
2+
import { useOvermind } from 'app/overmind';
23
// eslint-disable-next-line import/extensions
34
import getType from 'app/utils/get-type.ts';
45
import React from 'react';
56

67
import Entry from '../Entry';
78

8-
const ModuleEntry = ({
9-
store,
9+
interface IModuleEntryProps {
10+
module: Module;
11+
setCurrentModule: (id: string) => void;
12+
markTabsNotDirty: () => void;
13+
depth: number;
14+
renameModule: (title: string, moduleShortid: string) => void;
15+
deleteEntry: (shortid: string, title: string) => void;
16+
discardModuleChanges: (shortid: string) => void;
17+
getModulePath: (
18+
modules: Module[],
19+
directories: Directory[],
20+
id: string
21+
) => string;
22+
renameValidator: (id: string, title: string) => boolean;
23+
}
24+
25+
const ModuleEntry: React.FC<IModuleEntryProps> = ({
1026
module,
1127
setCurrentModule,
1228
markTabsNotDirty,
@@ -17,15 +33,17 @@ const ModuleEntry = ({
1733
getModulePath,
1834
renameValidator,
1935
}) => {
20-
const { currentModuleShortid } = store.editor;
21-
const mainModuleId = store.editor.mainModule.id;
22-
36+
const {
37+
state: {
38+
editor: { mainModule, currentModuleShortid },
39+
live,
40+
},
41+
} = useOvermind();
2342
const isActive = module.shortid === currentModuleShortid;
24-
const isMainModule = module.id === mainModuleId;
43+
const isMainModule = module.id === mainModule.id;
2544
const type = getType(module.title);
2645
const hasError = module.errors.length;
27-
28-
const liveUsers = store.live.liveUsersByModule[module.shortid] || [];
46+
const liveUsers = live.liveUsersByModule[module.shortid] || [];
2947

3048
const isNotSynced = module.savedCode && module.code !== module.savedCode;
3149

@@ -52,4 +70,4 @@ const ModuleEntry = ({
5270
);
5371
};
5472

55-
export default inject('store')(observer(ModuleEntry));
73+
export default ModuleEntry;

0 commit comments

Comments
 (0)