diff --git a/packages/ui/src/components/ContentReference/ChannelReference.tsx b/packages/ui/src/components/ContentReference/ChannelReference.tsx index 5fc5f71d64..3eba70ca27 100644 --- a/packages/ui/src/components/ContentReference/ChannelReference.tsx +++ b/packages/ui/src/components/ContentReference/ChannelReference.tsx @@ -2,6 +2,7 @@ import { getChannelType } from '@tloncorp/shared/dist/urbit'; import { PostViewMode } from '../ContentRenderer'; import ChatReferenceWrapper from './ChatReferenceWrapper'; +import NotebookReferenceWrapper from './NotebookReferenceWrapper'; import ReferenceSkeleton from './ReferenceSkeleton'; export default function ChannelReference({ @@ -32,11 +33,13 @@ export default function ChannelReference({ } if (channelType === 'notebook') { - // TODO: Implement notebook reference return ( - ); } diff --git a/packages/ui/src/components/ContentReference/ChatReference.tsx b/packages/ui/src/components/ContentReference/ChatReference.tsx index c582192448..b73c7e8b84 100644 --- a/packages/ui/src/components/ContentReference/ChatReference.tsx +++ b/packages/ui/src/components/ContentReference/ChatReference.tsx @@ -3,7 +3,7 @@ import { useCallback } from 'react'; import { ContactAvatar } from '../Avatar'; import ContactName from '../ContactName'; -import ChatContent, { PostViewMode } from '../ContentRenderer'; +import ContentRenderer, { PostViewMode } from '../ContentRenderer'; import { Reference } from './Reference'; export default function ChatReference({ @@ -51,7 +51,7 @@ export default function ChatReference({ - void; + asAttachment?: boolean; + viewMode?: PostViewMode; +}) { + const navigateToChannel = useCallback(() => { + if (asAttachment) { + return; + } + if (channel && post) { + onPress(channel, post); + } + }, [channel, onPress, post, asAttachment]); + + if (!post) { + return null; + } + + return ( + + + + + + + + + + + + + ); +} diff --git a/packages/ui/src/components/ContentReference/NotebookReferenceWrapper.tsx b/packages/ui/src/components/ContentReference/NotebookReferenceWrapper.tsx new file mode 100644 index 0000000000..04df1b5583 --- /dev/null +++ b/packages/ui/src/components/ContentReference/NotebookReferenceWrapper.tsx @@ -0,0 +1,63 @@ +import { useNavigation } from '../../contexts'; +import { useRequests } from '../../contexts/requests'; +import { PostViewMode } from '../ContentRenderer'; +import NotebookReference from './NotebookReference'; +import ReferenceSkeleton from './ReferenceSkeleton'; + +export default function NotebookReferenceWrapper({ + channelId, + postId, + replyId, + asAttachment = false, + viewMode = 'chat', +}: { + channelId: string; + postId: string; + replyId?: string; + asAttachment?: boolean; + viewMode?: PostViewMode; +}) { + const { usePostReference, useChannel } = useRequests(); + const { + data: post, + isError, + error, + isLoading, + } = usePostReference({ + postId: replyId ? replyId : postId, + channelId: channelId, + }); + const { data: channel } = useChannel({ id: channelId }); + const { onPressRef } = useNavigation(); + + if (isError) { + return ( + + ); + } + + if (!post) { + if (isLoading) { + return ; + } + return ( + + ); + } + + return ( + + ); +} diff --git a/packages/ui/src/components/ContentRenderer.tsx b/packages/ui/src/components/ContentRenderer.tsx index 1840b59865..a52c4d5909 100644 --- a/packages/ui/src/components/ContentRenderer.tsx +++ b/packages/ui/src/components/ContentRenderer.tsx @@ -851,16 +851,33 @@ export default function ContentRenderer({ if (shortened) { return ( - {shortenedInlines.length > 0 ? ( - + ) : null} + {post.type === 'note' && post.title ? ( + ) : null} + ); }