diff options
author | Thomas F. K. Jorna <[email protected]> | 2021-10-04 15:34:56 +0200 |
---|---|---|
committer | Thomas F. K. Jorna <[email protected]> | 2021-10-04 15:34:56 +0200 |
commit | b0ddf286f087b31dc75626f709cfce3889de25dd (patch) | |
tree | 480c65853ef0a8e2de44f567ec95e367fc634a04 /components/Sidebar/index.tsx | |
parent | 90820ca13a51b8a7e77d15896b0d34f9aba829fd (diff) |
feat(preview): changed text-retrieval to http
Diffstat (limited to 'components/Sidebar/index.tsx')
-rw-r--r-- | components/Sidebar/index.tsx | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/components/Sidebar/index.tsx b/components/Sidebar/index.tsx index e3845d9..05f5720 100644 --- a/components/Sidebar/index.tsx +++ b/components/Sidebar/index.tsx @@ -33,14 +33,25 @@ export interface SidebarProps { onClose: any //nodeById: any previewNode: NodeObject - orgText: string } const Sidebar = (props: SidebarProps) => { - const { isOpen, onClose, previewNode, orgText } = props + const { isOpen, onClose, previewNode } = props const { highlightColor } = useContext(ThemeContext) const [previewRoamNode, setPreviewRoamNode] = useState<OrgRoamNode>() + const [previewText, setPreviewText] = useState('') + + const getText = (id: string) => { + fetch(`http://localhost:35901/note/${id}`) + .then((res) => { + return res.text() + }) + .then((res) => { + console.log(res) + setPreviewText(res) + }) + } useEffect(() => { if (!previewNode) { @@ -48,6 +59,7 @@ const Sidebar = (props: SidebarProps) => { } setPreviewRoamNode(previewNode as OrgRoamNode) + previewNode?.id && getText(previewNode?.id as string) }, [previewNode]) //maybe want to close it when clicking outside, but not sure @@ -246,7 +258,7 @@ const Sidebar = (props: SidebarProps) => { '.figure p': { textAlign: 'center' }, }} > - <UniOrg orgText={orgText} /> + <UniOrg orgText={previewText} /> </Box> </VStack> </Scrollbars> |