Skip to content

Commit 5b0e509

Browse files
committed
refactor: remove access of node state through node
1 parent 671e446 commit 5b0e509

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

src/features/dashboard/sandbox/inspect/viewer.tsx

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33
import { useContent } from './hooks/use-content'
44
import { useShikiTheme } from '@/configs/shiki'
55
import ShikiHighlighter, { Language } from 'react-shiki'
6-
import { useFilesystemNode, useSelectedPath } from './hooks/use-node'
7-
import { FileType } from 'e2b'
6+
import { useSelectedPath } from './hooks/use-node'
87
import SandboxInspectFrame from './frame'
98
import SandboxInspectViewerHeader from './viewer-header'
109
import { ScrollArea, ScrollBar } from '@/ui/primitives/scroll-area'
11-
import { useFileOperations } from './hooks/use-file'
10+
import { useFile } from './hooks/use-file'
1211

1312
export default function SandboxInspectViewer() {
1413
const path = useSelectedPath()
@@ -21,19 +20,18 @@ export default function SandboxInspectViewer() {
2120
}
2221

2322
function SandboxInspectViewerContent({ path }: { path: string }) {
24-
const node = useFilesystemNode(path)
25-
const { refresh } = useFileOperations(path)
23+
const { name, isLoading, refresh } = useFile(path)
2624
const { content } = useContent(path)
2725
const shikiTheme = useShikiTheme()
2826

29-
if (content === undefined || node?.type !== FileType.FILE) {
27+
if (content === undefined) {
3028
return null
3129
}
3230

33-
const hasDot = node.name.includes('.')
34-
let language: Language = node.name.split('.').pop() ?? 'text'
31+
const hasDot = name.includes('.')
32+
let language: Language = name.split('.').pop() ?? 'text'
3533

36-
if (!hasDot || (node.name.startsWith('.') && language)) {
34+
if (!hasDot || (name.startsWith('.') && language)) {
3735
language = 'text'
3836
}
3937

@@ -42,9 +40,9 @@ function SandboxInspectViewerContent({ path }: { path: string }) {
4240
className="max-w-1/2"
4341
header={
4442
<SandboxInspectViewerHeader
45-
name={node.name}
43+
name={name}
4644
content={content}
47-
isLoading={node.isLoading ?? false}
45+
isLoading={isLoading}
4846
onRefresh={refresh}
4947
/>
5048
}

0 commit comments

Comments
 (0)