Skip to content

Commit 7646aee

Browse files
committed
feat: simplify DNamespaceProjectContent by removing unused services and optimizing project retrieval
1 parent 0d3fb77 commit 7646aee

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

src/components/d-project/DNamespaceProjectContent.tsx

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,16 @@ export const DNamespaceProjectContent: React.FC<DNamespaceProjectContentProps> =
2727
}
2828
} = props
2929
const projectService = useService(DNamespaceProjectReactiveService)
30-
const namespaceService = useService(DNamespaceReactiveService)
31-
const organizationService = useService(DOrganizationReactiveService)
32-
const userService = useService(DUserReactiveService)
3330
const runtimeService = useService(DRuntimeReactiveService)
3431

35-
const project = React.useMemo(() => projectService.getById(props.projectId), [projectService, props.projectId])
32+
const project = React.useMemo(() => projectService.getById(projectId), [projectService, projectId])
3633
const assignedRuntime = React.useMemo(() => project ? runtimeService.getById(project.primaryRuntime?.id) : null, [project])
37-
const namespace = React.useMemo(() => project ? namespaceService.getById(project.namespace?.id) : null, [namespaceService, project])
38-
const namespaceParent = React.useMemo(() => namespace && namespace.parent
39-
? (namespace.parent.__typename === "Organization"
40-
? organizationService.getById((namespace.parent as Organization).id)
41-
: namespace.parent.__typename === "User"
42-
? userService.getById((namespace.parent as User).id)
43-
: null)
44-
: null, [])
4534

4635
return (
4736
<Flex align={"center"} style={{gap: "1.3rem"}} justify={"space-between"}>
4837
<Flex align={"center"} style={{gap: "1.3rem"}}>
4938
<Avatar bg={"transparent"}
50-
identifier={
51-
(namespace?.parent?.__typename === "User"
52-
? (namespaceParent as DUserView).username
53-
: namespace?.parent?.__typename === "Organization"
54-
? (namespaceParent as DOrganizationView).name
55-
: "")
56-
?? ""
57-
}/>
39+
identifier={project?.name ?? ""}/>
5840
<Flex style={{flexDirection: "column", gap: "0.35rem"}}>
5941
<Text size={"lg"} hierarchy={"primary"} display={"block"}>
6042
{project?.name}

0 commit comments

Comments
 (0)