Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 38 additions & 23 deletions packages/mobile/src/components/comments/CommentDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import type { SearchCategory } from '@audius/common/api'
import {
useCurrentUserId,
useFollowers,
useSearchUserResults
useSearchUserResults,
useTrack
} from '@audius/common/api'
import type { ReplyingAndEditingState } from '@audius/common/context'
import {
Expand Down Expand Up @@ -238,6 +239,12 @@ export const CommentDrawer = (props: CommentDrawerProps) => {
const insets = useSafeAreaInsets()
const commentListRef = useRef<BottomSheetFlatListMethods>(null)

// When the drawer is opened from a lineup tile (e.g. the feed), the full
// track may not yet be in the query cache. CommentSectionProvider returns
// null until the track loads, which would render an empty bottom sheet, so
// fetch the track here and show a loading state instead of a blank drawer.
const { data: track } = useTrack(entityId)

const [onAutocomplete, setOnAutocomplete] = useState<
(user: UserMetadata) => void
>(() => {})
Expand Down Expand Up @@ -339,28 +346,36 @@ export const CommentDrawer = (props: CommentDrawerProps) => {
keyboardBlurBehavior='restore'
android_keyboardInputMode='adjustResize'
>
<CommentSectionProvider
entityId={entityId}
replyingAndEditingState={replyingAndEditingState}
setReplyingAndEditingState={setReplyingAndEditingState}
navigation={navigation}
closeDrawer={handleCloseDrawer}
playbackSource={playbackSource}
>
<CommentDrawerHeader minimal={autoCompleteActive} />
<Divider orientation='horizontal' />
{autoCompleteActive ? (
<CommentDrawerAutocompleteContent
query={acText}
onSelect={onAutocomplete}
/>
) : (
<CommentDrawerContent
commentListRef={commentListRef}
highlightedComment={highlightedComment}
/>
)}
</CommentSectionProvider>
{track ? (
<CommentSectionProvider
entityId={entityId}
replyingAndEditingState={replyingAndEditingState}
setReplyingAndEditingState={setReplyingAndEditingState}
navigation={navigation}
closeDrawer={handleCloseDrawer}
playbackSource={playbackSource}
>
<CommentDrawerHeader minimal={autoCompleteActive} />
<Divider orientation='horizontal' />
{autoCompleteActive ? (
<CommentDrawerAutocompleteContent
query={acText}
onSelect={onAutocomplete}
/>
) : (
<CommentDrawerContent
commentListRef={commentListRef}
highlightedComment={highlightedComment}
/>
)}
</CommentSectionProvider>
) : (
<>
<CommentSkeleton />
<CommentSkeleton />
<CommentSkeleton />
</>
)}
</BottomSheetModal>
{isDrawerVisible ? (
<Box
Expand Down
Loading