summaryrefslogtreecommitdiff
path: root/components/Sidebar/index.tsx
diff options
context:
space:
mode:
authorThomas F. K. Jorna <[email protected]>2021-10-04 15:34:56 +0200
committerThomas F. K. Jorna <[email protected]>2021-10-04 15:34:56 +0200
commitb0ddf286f087b31dc75626f709cfce3889de25dd (patch)
tree480c65853ef0a8e2de44f567ec95e367fc634a04 /components/Sidebar/index.tsx
parent90820ca13a51b8a7e77d15896b0d34f9aba829fd (diff)
feat(preview): changed text-retrieval to http
Diffstat (limited to 'components/Sidebar/index.tsx')
-rw-r--r--components/Sidebar/index.tsx18
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>