[Chat] Remove convoState dependency from header (#10293)
This commit is contained in:
@@ -190,7 +190,7 @@ function MenuContent({
|
|||||||
const isDeletedAccount = profile.handle === 'missing.invalid'
|
const isDeletedAccount = profile.handle === 'missing.invalid'
|
||||||
|
|
||||||
const convoId = initialConvo.id
|
const convoId = initialConvo.id
|
||||||
const {data: convo} = useConvoQuery(initialConvo)
|
const {data: convo} = useConvoQuery({convoId})
|
||||||
|
|
||||||
const onNavigateToProfile = useCallback(() => {
|
const onNavigateToProfile = useCallback(() => {
|
||||||
navigation.navigate('Profile', {name: profile.did})
|
navigation.navigate('Profile', {name: profile.did})
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import {useMemo} from 'react'
|
import {useMemo} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
import {
|
import {
|
||||||
type AppBskyActorDefs,
|
|
||||||
ChatBskyConvoDefs,
|
ChatBskyConvoDefs,
|
||||||
type ModerationCause,
|
moderateProfile,
|
||||||
type ModerationDecision,
|
type ModerationOpts,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
import {useLingui} from '@lingui/react/macro'
|
import {useLingui} from '@lingui/react/macro'
|
||||||
import {useNavigation} from '@react-navigation/native'
|
import {useNavigation} from '@react-navigation/native'
|
||||||
@@ -12,7 +11,8 @@ import {useNavigation} from '@react-navigation/native'
|
|||||||
import {createSanitizedDisplayName} from '#/lib/moderation/create-sanitized-display-name'
|
import {createSanitizedDisplayName} from '#/lib/moderation/create-sanitized-display-name'
|
||||||
import {makeProfileLink} from '#/lib/routes/links'
|
import {makeProfileLink} from '#/lib/routes/links'
|
||||||
import {type NavigationProp} from '#/lib/routes/types'
|
import {type NavigationProp} from '#/lib/routes/types'
|
||||||
import {type Shadow} from '#/state/cache/profile-shadow'
|
import {useProfileShadow} from '#/state/cache/profile-shadow'
|
||||||
|
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
import {PreviewableUserAvatar} from '#/view/com/util/UserAvatar'
|
import {PreviewableUserAvatar} from '#/view/com/util/UserAvatar'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
@@ -30,30 +30,9 @@ import {type ConvoWithDetails} from './util'
|
|||||||
|
|
||||||
const PFP_SIZE = IS_WEB ? 40 : Layout.HEADER_SLOT_SIZE
|
const PFP_SIZE = IS_WEB ? 40 : Layout.HEADER_SLOT_SIZE
|
||||||
|
|
||||||
export function MessagesListHeader({
|
export function MessagesListHeader({convo}: {convo?: ConvoWithDetails | null}) {
|
||||||
convo,
|
|
||||||
profile,
|
|
||||||
moderation,
|
|
||||||
}: {
|
|
||||||
convo?: ConvoWithDetails | null
|
|
||||||
profile?: Shadow<AppBskyActorDefs.ProfileViewDetailed>
|
|
||||||
moderation?: ModerationDecision | null
|
|
||||||
}) {
|
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
|
const moderationOpts = useModerationOpts()
|
||||||
const isGroupChat = convo?.kind === 'group'
|
|
||||||
|
|
||||||
const blockInfo = useMemo(() => {
|
|
||||||
if (!moderation) return
|
|
||||||
const modui = moderation.ui('profileView')
|
|
||||||
const blocks = modui.alerts.filter(alert => alert.type === 'blocking')
|
|
||||||
const listBlocks = blocks.filter(alert => alert.source.type === 'list')
|
|
||||||
const userBlock = blocks.find(alert => alert.source.type === 'user')
|
|
||||||
return {
|
|
||||||
listBlocks,
|
|
||||||
userBlock,
|
|
||||||
}
|
|
||||||
}, [moderation])
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout.Header.Outer noBottomBorder={IS_LIQUID_GLASS}>
|
<Layout.Header.Outer noBottomBorder={IS_LIQUID_GLASS}>
|
||||||
@@ -61,20 +40,11 @@ export function MessagesListHeader({
|
|||||||
<View style={[{minHeight: PFP_SIZE}, a.justify_center]}>
|
<View style={[{minHeight: PFP_SIZE}, a.justify_center]}>
|
||||||
<Layout.Header.BackButton />
|
<Layout.Header.BackButton />
|
||||||
</View>
|
</View>
|
||||||
{convo ? (
|
{convo && moderationOpts ? (
|
||||||
moderation && blockInfo && profile && !isGroupChat ? (
|
convo.kind === 'direct' ? (
|
||||||
<ProfileHeaderReady
|
<ProfileHeaderReady convo={convo} moderationOpts={moderationOpts} />
|
||||||
convo={convo}
|
|
||||||
profile={profile}
|
|
||||||
moderation={moderation}
|
|
||||||
blockInfo={blockInfo}
|
|
||||||
/>
|
|
||||||
) : (
|
) : (
|
||||||
<GroupHeaderReady
|
<GroupHeaderReady convo={convo} />
|
||||||
convo={convo}
|
|
||||||
profile={profile}
|
|
||||||
moderation={moderation}
|
|
||||||
/>
|
|
||||||
)
|
)
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
@@ -108,20 +78,27 @@ export function MessagesListHeader({
|
|||||||
|
|
||||||
function ProfileHeaderReady({
|
function ProfileHeaderReady({
|
||||||
convo,
|
convo,
|
||||||
profile,
|
moderationOpts,
|
||||||
moderation,
|
|
||||||
blockInfo,
|
|
||||||
}: {
|
}: {
|
||||||
convo: ConvoWithDetails
|
convo: Extract<ConvoWithDetails, {kind: 'direct'}>
|
||||||
profile: Shadow<AppBskyActorDefs.ProfileViewDetailed>
|
moderationOpts: ModerationOpts
|
||||||
moderation: ModerationDecision
|
|
||||||
blockInfo: {
|
|
||||||
listBlocks: ModerationCause[]
|
|
||||||
userBlock?: ModerationCause
|
|
||||||
}
|
|
||||||
}) {
|
}) {
|
||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
const profile = useProfileShadow(convo.primaryMember)
|
||||||
|
|
||||||
|
const moderation = moderateProfile(profile, moderationOpts)
|
||||||
|
|
||||||
|
const blockInfo = useMemo(() => {
|
||||||
|
const modui = moderation.ui('profileView')
|
||||||
|
const blocks = modui.alerts.filter(alert => alert.type === 'blocking')
|
||||||
|
const listBlocks = blocks.filter(alert => alert.source.type === 'list')
|
||||||
|
const userBlock = blocks.find(alert => alert.source.type === 'user')
|
||||||
|
return {
|
||||||
|
listBlocks,
|
||||||
|
userBlock,
|
||||||
|
}
|
||||||
|
}, [moderation])
|
||||||
|
|
||||||
const isDeletedAccount = profile?.handle === 'missing.invalid'
|
const isDeletedAccount = profile?.handle === 'missing.invalid'
|
||||||
const displayName = isDeletedAccount
|
const displayName = isDeletedAccount
|
||||||
@@ -171,29 +148,13 @@ function ProfileHeaderReady({
|
|||||||
|
|
||||||
function GroupHeaderReady({
|
function GroupHeaderReady({
|
||||||
convo,
|
convo,
|
||||||
profile,
|
|
||||||
moderation,
|
|
||||||
}: {
|
}: {
|
||||||
convo: ConvoWithDetails
|
convo: Extract<ConvoWithDetails, {kind: 'group'}>
|
||||||
profile?: Shadow<AppBskyActorDefs.ProfileViewDetailed>
|
|
||||||
moderation?: ModerationDecision | null
|
|
||||||
}) {
|
}) {
|
||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
|
|
||||||
const navigation = useNavigation<NavigationProp>()
|
const navigation = useNavigation<NavigationProp>()
|
||||||
|
|
||||||
const groupInfo = convo.kind === 'group' ? convo.details : undefined
|
|
||||||
|
|
||||||
const isDeletedAccount = profile?.handle === 'missing.invalid'
|
|
||||||
const displayName = isDeletedAccount
|
|
||||||
? l`Deleted Account`
|
|
||||||
: profile
|
|
||||||
? createSanitizedDisplayName(profile, true, moderation?.ui('displayName'))
|
|
||||||
: undefined
|
|
||||||
const groupName =
|
|
||||||
groupInfo?.name ??
|
|
||||||
(displayName ? l`${displayName}’s group chat` : l`Group chat`)
|
|
||||||
|
|
||||||
const handleNavigateToSettings = () => {
|
const handleNavigateToSettings = () => {
|
||||||
navigation.navigate('MessagesConversationSettings', {
|
navigation.navigate('MessagesConversationSettings', {
|
||||||
conversation: convo.view.id,
|
conversation: convo.view.id,
|
||||||
@@ -206,7 +167,7 @@ function GroupHeaderReady({
|
|||||||
<>
|
<>
|
||||||
<AvatarBubbles size="small" profiles={convo.members} />
|
<AvatarBubbles size="small" profiles={convo.members} />
|
||||||
<Text style={[a.text_md, a.font_semi_bold]} numberOfLines={1}>
|
<Text style={[a.text_md, a.font_semi_bold]} numberOfLines={1}>
|
||||||
{groupName}
|
{convo.details.name}
|
||||||
</Text>
|
</Text>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,12 +56,12 @@ export function hasReachedReactionLimit(
|
|||||||
return myReactions.length >= EMOJI_REACTION_LIMIT
|
return myReactions.length >= EMOJI_REACTION_LIMIT
|
||||||
}
|
}
|
||||||
|
|
||||||
type GroupConvoMember = ChatBskyActorDefs.ProfileViewBasic & {
|
export type GroupConvoMember = ChatBskyActorDefs.ProfileViewBasic & {
|
||||||
// can be missing if account deleted
|
// can be missing if account deleted
|
||||||
kind?: $Typed<ChatBskyActorDefs.GroupConvoMember>
|
kind?: $Typed<ChatBskyActorDefs.GroupConvoMember>
|
||||||
}
|
}
|
||||||
|
|
||||||
type DirectConvoMember = ChatBskyActorDefs.ProfileViewBasic & {
|
export type DirectConvoMember = ChatBskyActorDefs.ProfileViewBasic & {
|
||||||
kind: $Typed<ChatBskyActorDefs.DirectConvoMember>
|
kind: $Typed<ChatBskyActorDefs.DirectConvoMember>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import {useCallback, useEffect, useMemo, useState} from 'react'
|
import {useCallback, useEffect, useMemo, useState} from 'react'
|
||||||
import {type LayoutChangeEvent, View} from 'react-native'
|
import {type LayoutChangeEvent, View} from 'react-native'
|
||||||
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||||
import {
|
import {moderateProfile} from '@atproto/api'
|
||||||
type AppBskyActorDefs,
|
|
||||||
moderateProfile,
|
|
||||||
type ModerationDecision,
|
|
||||||
} from '@atproto/api'
|
|
||||||
import {
|
import {
|
||||||
ScrollEdgeEffect,
|
ScrollEdgeEffect,
|
||||||
ScrollEdgeEffectProvider,
|
ScrollEdgeEffectProvider,
|
||||||
@@ -28,13 +24,13 @@ import {
|
|||||||
type CommonNavigatorParams,
|
type CommonNavigatorParams,
|
||||||
type NavigationProp,
|
type NavigationProp,
|
||||||
} from '#/lib/routes/types'
|
} from '#/lib/routes/types'
|
||||||
import {type Shadow, useMaybeProfileShadow} from '#/state/cache/profile-shadow'
|
import {useMaybeProfileShadow} from '#/state/cache/profile-shadow'
|
||||||
import {useEmail} from '#/state/email-verification'
|
import {useEmail} from '#/state/email-verification'
|
||||||
import {ConvoProvider, isConvoActive, useConvo} from '#/state/messages/convo'
|
import {ConvoProvider, isConvoActive, useConvo} from '#/state/messages/convo'
|
||||||
import {ConvoStatus} from '#/state/messages/convo/types'
|
import {ConvoStatus} from '#/state/messages/convo/types'
|
||||||
import {useCurrentConvoId} from '#/state/messages/current-convo-id'
|
import {useCurrentConvoId} from '#/state/messages/current-convo-id'
|
||||||
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
||||||
import {useProfileQuery} from '#/state/queries/profile'
|
import {useConvoQuery} from '#/state/queries/messages/conversation'
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
import {useSetMinimalShellMode} from '#/state/shell'
|
import {useSetMinimalShellMode} from '#/state/shell'
|
||||||
import {MessagesList} from '#/screens/Messages/components/MessagesList'
|
import {MessagesList} from '#/screens/Messages/components/MessagesList'
|
||||||
@@ -52,6 +48,7 @@ import {Error} from '#/components/Error'
|
|||||||
import * as Layout from '#/components/Layout'
|
import * as Layout from '#/components/Layout'
|
||||||
import {Loader} from '#/components/Loader'
|
import {Loader} from '#/components/Loader'
|
||||||
import {IS_LIQUID_GLASS, IS_WEB} from '#/env'
|
import {IS_LIQUID_GLASS, IS_WEB} from '#/env'
|
||||||
|
import {ChatDisabled} from './components/ChatDisabled'
|
||||||
|
|
||||||
type Props = NativeStackScreenProps<
|
type Props = NativeStackScreenProps<
|
||||||
CommonNavigatorParams,
|
CommonNavigatorParams,
|
||||||
@@ -95,36 +92,26 @@ export function MessagesConversationScreenInner({route}: Props) {
|
|||||||
style={web([{minHeight: 0}, a.flex_1])}>
|
style={web([{minHeight: 0}, a.flex_1])}>
|
||||||
<ScrollEdgeEffectProvider>
|
<ScrollEdgeEffectProvider>
|
||||||
<ConvoProvider key={convoId} convoId={convoId}>
|
<ConvoProvider key={convoId} convoId={convoId}>
|
||||||
<Inner />
|
<Inner convoId={convoId} />
|
||||||
</ConvoProvider>
|
</ConvoProvider>
|
||||||
</ScrollEdgeEffectProvider>
|
</ScrollEdgeEffectProvider>
|
||||||
</Layout.Screen>
|
</Layout.Screen>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Inner() {
|
function Inner({convoId}: {convoId: string}) {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const convoState = useConvo()
|
const convoState = useConvo()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
const isFocused = useIsFocused()
|
const isFocused = useIsFocused()
|
||||||
const {top: topInset} = useSafeAreaInsets()
|
const {top: topInset} = useSafeAreaInsets()
|
||||||
|
const {data: convoData} = useConvoQuery({convoId})
|
||||||
|
|
||||||
const convo = convoState.convo
|
const convo = convoData
|
||||||
? parseConvoView(convoState.convo, currentAccount?.did)
|
? parseConvoView(convoData, currentAccount?.did)
|
||||||
: null
|
: null
|
||||||
|
|
||||||
const moderationOpts = useModerationOpts()
|
|
||||||
const {data: recipientUnshadowed} = useProfileQuery({
|
|
||||||
did: convoState.getPrimaryMember?.()?.did,
|
|
||||||
})
|
|
||||||
const recipient = useMaybeProfileShadow(recipientUnshadowed)
|
|
||||||
|
|
||||||
const moderation = useMemo(() => {
|
|
||||||
if (!recipient || !moderationOpts) return null
|
|
||||||
return moderateProfile(recipient, moderationOpts)
|
|
||||||
}, [recipient, moderationOpts])
|
|
||||||
|
|
||||||
// Because we want to give the list a chance to asynchronously scroll to the end before it is visible to the user,
|
// Because we want to give the list a chance to asynchronously scroll to the end before it is visible to the user,
|
||||||
// we use `hasScrolled` to determine when to render. With that said however, there is a chance that the chat will be
|
// we use `hasScrolled` to determine when to render. With that said however, there is a chance that the chat will be
|
||||||
// empty. So, we also check for that possible state as well and render once we can.
|
// empty. So, we also check for that possible state as well and render once we can.
|
||||||
@@ -150,15 +137,7 @@ function Inner() {
|
|||||||
<>
|
<>
|
||||||
<Layout.Center
|
<Layout.Center
|
||||||
style={[a.w_full, IS_LIQUID_GLASS && {paddingTop: topInset}]}>
|
style={[a.w_full, IS_LIQUID_GLASS && {paddingTop: topInset}]}>
|
||||||
{moderation ? (
|
<MessagesListHeader convo={convo} />
|
||||||
<MessagesListHeader
|
|
||||||
convo={convo}
|
|
||||||
profile={recipient}
|
|
||||||
moderation={moderation}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<MessagesListHeader convo={convo} />
|
|
||||||
)}
|
|
||||||
</Layout.Center>
|
</Layout.Center>
|
||||||
<Error
|
<Error
|
||||||
title={_(msg`Something went wrong`)}
|
title={_(msg`Something went wrong`)}
|
||||||
@@ -176,25 +155,16 @@ function Inner() {
|
|||||||
{isFocused && IS_WEB && <RemoveScrollBar />}
|
{isFocused && IS_WEB && <RemoveScrollBar />}
|
||||||
{!readyToShow && (
|
{!readyToShow && (
|
||||||
<View style={IS_LIQUID_GLASS && {paddingTop: topInset}}>
|
<View style={IS_LIQUID_GLASS && {paddingTop: topInset}}>
|
||||||
{moderation ? (
|
<MessagesListHeader convo={convo} />
|
||||||
<MessagesListHeader
|
|
||||||
convo={convo}
|
|
||||||
profile={recipient}
|
|
||||||
moderation={moderation}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<MessagesListHeader convo={convo} />
|
|
||||||
)}
|
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
<View style={[a.flex_1]}>
|
<View style={[a.flex_1]}>
|
||||||
<InnerReady
|
<InnerReady
|
||||||
moderation={moderation}
|
convo={convo}
|
||||||
recipient={recipient}
|
|
||||||
hasScrolled={hasScrolled}
|
hasScrolled={hasScrolled}
|
||||||
setHasScrolled={setHasScrolled}
|
setHasScrolled={setHasScrolled}
|
||||||
convo={convo}
|
|
||||||
isActive={isConvoActive(convoState)}
|
isActive={isConvoActive(convoState)}
|
||||||
|
isDisabled={convoState.status === ConvoStatus.Disabled}
|
||||||
hasMessages={isConvoActive(convoState) && convoState.items.length > 0}
|
hasMessages={isConvoActive(convoState) && convoState.items.length > 0}
|
||||||
/>
|
/>
|
||||||
{!readyToShow && (
|
{!readyToShow && (
|
||||||
@@ -219,20 +189,18 @@ function Inner() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function InnerReady({
|
function InnerReady({
|
||||||
moderation,
|
|
||||||
recipient,
|
|
||||||
hasScrolled,
|
hasScrolled,
|
||||||
setHasScrolled,
|
setHasScrolled,
|
||||||
convo,
|
convo,
|
||||||
isActive,
|
isActive,
|
||||||
|
isDisabled,
|
||||||
hasMessages,
|
hasMessages,
|
||||||
}: {
|
}: {
|
||||||
moderation: ModerationDecision | null
|
|
||||||
recipient: Shadow<AppBskyActorDefs.ProfileViewDetailed> | undefined
|
|
||||||
hasScrolled: boolean
|
hasScrolled: boolean
|
||||||
setHasScrolled: React.Dispatch<React.SetStateAction<boolean>>
|
setHasScrolled: React.Dispatch<React.SetStateAction<boolean>>
|
||||||
convo: ConvoWithDetails | null
|
convo: ConvoWithDetails | null
|
||||||
isActive: boolean
|
isActive: boolean
|
||||||
|
isDisabled: boolean
|
||||||
hasMessages: boolean
|
hasMessages: boolean
|
||||||
}) {
|
}) {
|
||||||
const navigation = useNavigation<NavigationProp>()
|
const navigation = useNavigation<NavigationProp>()
|
||||||
@@ -284,13 +252,14 @@ function InnerReady({
|
|||||||
maybeBlockForEmailVerification()
|
maybeBlockForEmailVerification()
|
||||||
}, [maybeBlockForEmailVerification])
|
}, [maybeBlockForEmailVerification])
|
||||||
|
|
||||||
const header = (
|
const primaryMember = useMaybeProfileShadow(convo?.primaryMember)
|
||||||
<MessagesListHeader
|
const moderationOpts = useModerationOpts()
|
||||||
convo={convo}
|
const primaryMemberModeration = useMemo(() => {
|
||||||
profile={recipient}
|
if (!primaryMember || !moderationOpts) return null
|
||||||
moderation={moderation}
|
return moderateProfile(primaryMember, moderationOpts)
|
||||||
/>
|
}, [primaryMember, moderationOpts])
|
||||||
)
|
|
||||||
|
const header = <MessagesListHeader convo={convo} />
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -308,16 +277,17 @@ function InnerReady({
|
|||||||
<MessagesList
|
<MessagesList
|
||||||
hasScrolled={hasScrolled}
|
hasScrolled={hasScrolled}
|
||||||
setHasScrolled={setHasScrolled}
|
setHasScrolled={setHasScrolled}
|
||||||
blocked={moderation?.blocked}
|
|
||||||
hasAcceptOverride={!!params.accept}
|
hasAcceptOverride={!!params.accept}
|
||||||
transparentHeaderHeight={IS_LIQUID_GLASS ? headerHeight : 0}
|
transparentHeaderHeight={IS_LIQUID_GLASS ? headerHeight : 0}
|
||||||
footer={
|
footer={
|
||||||
moderation && recipient && convo ? (
|
isDisabled ? (
|
||||||
|
<ChatDisabled />
|
||||||
|
) : convo && primaryMember && primaryMemberModeration?.blocked ? (
|
||||||
<MessagesListBlockedFooter
|
<MessagesListBlockedFooter
|
||||||
recipient={recipient}
|
recipient={primaryMember}
|
||||||
convoId={convo.view.id}
|
convoId={convo.view.id}
|
||||||
hasMessages={hasMessages}
|
hasMessages={hasMessages}
|
||||||
moderation={moderation}
|
moderation={primaryMemberModeration}
|
||||||
/>
|
/>
|
||||||
) : null
|
) : null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -482,6 +482,7 @@ function BaseChatItem({
|
|||||||
]
|
]
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
|
onPressIn={() => precacheConvoQuery(queryClient, convo)}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
onLongPress={showMenu && IS_NATIVE ? onLongPress : undefined}
|
onLongPress={showMenu && IS_NATIVE ? onLongPress : undefined}
|
||||||
onAccessibilityAction={showMenu ? onLongPress : undefined}>
|
onAccessibilityAction={showMenu ? onLongPress : undefined}>
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ import {
|
|||||||
import {useGetPost} from '#/state/queries/post'
|
import {useGetPost} from '#/state/queries/post'
|
||||||
import {useAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
import {List, type ListMethods} from '#/view/com/util/List'
|
import {List, type ListMethods} from '#/view/com/util/List'
|
||||||
import {ChatDisabled} from '#/screens/Messages/components/ChatDisabled'
|
|
||||||
import {MessageComposer} from '#/screens/Messages/components/MessageComposer'
|
import {MessageComposer} from '#/screens/Messages/components/MessageComposer'
|
||||||
import {MessageInput} from '#/screens/Messages/components/MessageInput'
|
import {MessageInput} from '#/screens/Messages/components/MessageInput'
|
||||||
import {MessageListError} from '#/screens/Messages/components/MessageListError'
|
import {MessageListError} from '#/screens/Messages/components/MessageListError'
|
||||||
@@ -93,14 +92,12 @@ function onScrollToIndexFailed() {
|
|||||||
export function MessagesList({
|
export function MessagesList({
|
||||||
hasScrolled,
|
hasScrolled,
|
||||||
setHasScrolled,
|
setHasScrolled,
|
||||||
blocked,
|
|
||||||
footer,
|
footer,
|
||||||
hasAcceptOverride,
|
hasAcceptOverride,
|
||||||
transparentHeaderHeight,
|
transparentHeaderHeight,
|
||||||
}: {
|
}: {
|
||||||
hasScrolled: boolean
|
hasScrolled: boolean
|
||||||
setHasScrolled: React.Dispatch<React.SetStateAction<boolean>>
|
setHasScrolled: React.Dispatch<React.SetStateAction<boolean>>
|
||||||
blocked?: boolean
|
|
||||||
footer?: React.ReactNode
|
footer?: React.ReactNode
|
||||||
hasAcceptOverride?: boolean
|
hasAcceptOverride?: boolean
|
||||||
transparentHeaderHeight?: number
|
transparentHeaderHeight?: number
|
||||||
@@ -489,11 +486,7 @@ export function MessagesList({
|
|||||||
}),
|
}),
|
||||||
opened: 0,
|
opened: 0,
|
||||||
}}>
|
}}>
|
||||||
{convoState.status === ConvoStatus.Disabled ? (
|
{footer ?? (
|
||||||
<ChatDisabled />
|
|
||||||
) : blocked ? (
|
|
||||||
footer
|
|
||||||
) : (
|
|
||||||
<ConversationFooter
|
<ConversationFooter
|
||||||
convoState={convoState}
|
convoState={convoState}
|
||||||
hasAcceptOverride={hasAcceptOverride}>
|
hasAcceptOverride={hasAcceptOverride}>
|
||||||
|
|||||||
@@ -19,19 +19,18 @@ import {
|
|||||||
const RQKEY_ROOT = 'convo'
|
const RQKEY_ROOT = 'convo'
|
||||||
export const RQKEY = (convoId: string) => [RQKEY_ROOT, convoId]
|
export const RQKEY = (convoId: string) => [RQKEY_ROOT, convoId]
|
||||||
|
|
||||||
export function useConvoQuery(convo: ChatBskyConvoDefs.ConvoView) {
|
export function useConvoQuery({convoId}: {convoId: string}) {
|
||||||
const agent = useAgent()
|
const agent = useAgent()
|
||||||
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: RQKEY(convo.id),
|
queryKey: RQKEY(convoId),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const {data} = await agent.chat.bsky.convo.getConvo(
|
const {data} = await agent.chat.bsky.convo.getConvo(
|
||||||
{convoId: convo.id},
|
{convoId},
|
||||||
{headers: DM_SERVICE_HEADERS},
|
{headers: DM_SERVICE_HEADERS},
|
||||||
)
|
)
|
||||||
return data.convo
|
return data.convo
|
||||||
},
|
},
|
||||||
initialData: convo,
|
|
||||||
staleTime: STALE.INFINITY,
|
staleTime: STALE.INFINITY,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -58,7 +57,7 @@ export function useMarkAsReadMutation() {
|
|||||||
}) => {
|
}) => {
|
||||||
if (!convoId) throw new Error('No convoId provided')
|
if (!convoId) throw new Error('No convoId provided')
|
||||||
|
|
||||||
await agent.api.chat.bsky.convo.updateRead(
|
await agent.chat.bsky.convo.updateRead(
|
||||||
{
|
{
|
||||||
convoId,
|
convoId,
|
||||||
messageId,
|
messageId,
|
||||||
|
|||||||
Reference in New Issue
Block a user