From 83ca76b6b4ba512caccd0b5316eeb7628a5dce69 Mon Sep 17 00:00:00 2001 From: sawka Date: Fri, 21 Jun 2024 16:22:59 -0700 Subject: [PATCH] only materialize the fileContentAtom when necessary --- frontend/app/view/preview.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/frontend/app/view/preview.tsx b/frontend/app/view/preview.tsx index e4439be8d..f142bc773 100644 --- a/frontend/app/view/preview.tsx +++ b/frontend/app/view/preview.tsx @@ -108,6 +108,19 @@ function StreamingPreview({ fileInfo }: { fileInfo: FileInfo }) { return Preview Not Supported; } +function CodeEditPreview({ + contentAtom, + filename, + readonly, +}: { + contentAtom: jotai.Atom>; + filename: string; + readonly: boolean; +}) { + const fileContent = jotai.useAtomValue(contentAtom); + return ; +} + function PreviewView({ blockId }: { blockId: string }) { const blockAtom = WOS.getWaveObjectAtom(`block:${blockId}`); const fileNameAtom: jotai.WritableAtom = useBlockCache(blockId, "preview:filename", () => @@ -161,7 +174,6 @@ function PreviewView({ blockId }: { blockId: string }) { } let fileName = jotai.useAtomValue(fileNameAtom); const fileInfo = jotai.useAtomValue(statFileAtom); - const fileContent = jotai.useAtomValue(fileContentAtom); // handle streaming files here let specializedView: React.ReactNode; @@ -197,7 +209,7 @@ function PreviewView({ blockId }: { blockId: string }) { (mimeType.includes("json") || mimeType.includes("yaml") || mimeType.includes("toml"))) ) { blockIcon = "file-code"; - specializedView = specializedView = ; + specializedView = ; } else if (mimeType === "directory") { blockIcon = "folder"; if (fileName == "~" || fileName == "~/") {