Skip to content

Commit 7a9e640

Browse files
committed
Merge branch 'master' of github.com:codesandbox/codesandbox-client into new-modals
2 parents 0921003 + fb6c381 commit 7a9e640

File tree

5 files changed

+202
-166
lines changed

5 files changed

+202
-166
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Explorer/Files/DirectoryEntry/DirectoryChildren/ModuleEntry.tsx

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -22,55 +22,58 @@ interface IModuleEntryProps {
2222
id: string
2323
) => string;
2424
renameValidator?: (id: string, title: string) => string | false | null;
25+
isActive: boolean;
2526
}
2627

27-
const ModuleEntry: React.FC<IModuleEntryProps> = ({
28-
module,
29-
setCurrentModule,
30-
markTabsNotDirty,
31-
depth,
32-
renameModule,
33-
deleteEntry,
34-
discardModuleChanges,
35-
getModulePath,
36-
renameValidator,
37-
}) => {
38-
const {
39-
state: {
40-
editor: { mainModule, currentModuleShortid },
41-
live,
42-
},
43-
} = useOvermind();
44-
const isActive = module.shortid === currentModuleShortid;
45-
const isMainModule = module.id === mainModule.id;
46-
const type = getType(module.title);
47-
const hasError = module.errors.length > 0;
48-
const liveUsers = live.liveUsersByModule[module.shortid] || [];
28+
const ModuleEntry: React.FC<IModuleEntryProps> = React.memo(
29+
({
30+
module,
31+
setCurrentModule,
32+
markTabsNotDirty,
33+
depth,
34+
renameModule,
35+
deleteEntry,
36+
discardModuleChanges,
37+
getModulePath,
38+
renameValidator,
39+
isActive,
40+
}) => {
41+
const {
42+
state: {
43+
editor: { mainModule },
44+
live,
45+
},
46+
} = useOvermind();
47+
const isMainModule = module.id === mainModule.id;
48+
const type = getType(module.title);
49+
const hasError = module.errors.length > 0;
50+
const liveUsers = live.liveUsersByModule[module.shortid] || [];
4951

50-
const isNotSynced = module.savedCode && module.code !== module.savedCode;
52+
const isNotSynced = module.savedCode && module.code !== module.savedCode;
5153

52-
return (
53-
// @ts-ignore
54-
<Entry
55-
id={module.id}
56-
shortid={module.shortid}
57-
title={module.title}
58-
rightColors={liveUsers.map(([a, b, c]) => `rgb(${a}, ${b}, ${c})`)}
59-
depth={depth + 1}
60-
active={isActive}
61-
type={type || 'function'}
62-
rename={renameModule}
63-
deleteEntry={deleteEntry}
64-
isNotSynced={isNotSynced}
65-
renameValidator={renameValidator}
66-
setCurrentModule={setCurrentModule}
67-
isMainModule={isMainModule}
68-
moduleHasError={hasError}
69-
markTabsNotDirty={markTabsNotDirty}
70-
discardModuleChanges={discardModuleChanges}
71-
getModulePath={getModulePath}
72-
/>
73-
);
74-
};
54+
return (
55+
// @ts-ignore
56+
<Entry
57+
id={module.id}
58+
shortid={module.shortid}
59+
title={module.title}
60+
rightColors={liveUsers.map(([a, b, c]) => `rgb(${a}, ${b}, ${c})`)}
61+
depth={depth + 1}
62+
active={isActive}
63+
type={type || 'function'}
64+
rename={renameModule}
65+
deleteEntry={deleteEntry}
66+
isNotSynced={isNotSynced}
67+
renameValidator={renameValidator}
68+
setCurrentModule={setCurrentModule}
69+
isMainModule={isMainModule}
70+
moduleHasError={hasError}
71+
markTabsNotDirty={markTabsNotDirty}
72+
discardModuleChanges={discardModuleChanges}
73+
getModulePath={getModulePath}
74+
/>
75+
);
76+
}
77+
);
7578

7679
export default ModuleEntry;

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Explorer/Files/DirectoryEntry/DirectoryChildren/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ const DirectoryChildren: React.FC<IDirectoryChildrenProps> = ({
7474
mainModuleId={mainModule.id}
7575
modules={modules}
7676
directories={directories}
77-
currentModuleShortid={currentModuleShortid}
7877
isInProjectView={isInProjectView}
7978
markTabsNotDirty={markTabsNotDirty}
8079
getModulePath={getModulePath}
@@ -95,6 +94,7 @@ const DirectoryChildren: React.FC<IDirectoryChildrenProps> = ({
9594
discardModuleChanges={discardModuleChanges}
9695
getModulePath={getModulePath}
9796
renameValidator={renameValidator}
97+
isActive={m.shortid === currentModuleShortid}
9898
/>
9999
))}
100100
</div>

0 commit comments

Comments
 (0)