[Chat] Request screen tweaks (#10747)
This commit is contained in:
@@ -26,10 +26,9 @@ import {useLeftConvos} from '#/state/queries/messages/leave-conversation'
|
|||||||
import {useListConvosQuery} from '#/state/queries/messages/list-conversations'
|
import {useListConvosQuery} from '#/state/queries/messages/list-conversations'
|
||||||
import {useUpdateAllRead} from '#/state/queries/messages/update-all-read'
|
import {useUpdateAllRead} from '#/state/queries/messages/update-all-read'
|
||||||
import {EmptyState} from '#/view/com/util/EmptyState'
|
import {EmptyState} from '#/view/com/util/EmptyState'
|
||||||
import {FAB} from '#/view/com/util/fab/FAB'
|
|
||||||
import {List} from '#/view/com/util/List'
|
import {List} from '#/view/com/util/List'
|
||||||
import {ChatListLoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder'
|
import {ChatListLoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder'
|
||||||
import {atoms as a, useBreakpoints, useTheme, web} from '#/alf'
|
import {atoms as a, useTheme, web} from '#/alf'
|
||||||
import {AgeRestrictedScreen} from '#/components/ageAssurance/AgeRestrictedScreen'
|
import {AgeRestrictedScreen} from '#/components/ageAssurance/AgeRestrictedScreen'
|
||||||
import {useAgeAssuranceCopy} from '#/components/ageAssurance/useAgeAssuranceCopy'
|
import {useAgeAssuranceCopy} from '#/components/ageAssurance/useAgeAssuranceCopy'
|
||||||
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
import {Button, ButtonIcon, ButtonText} from '#/components/Button'
|
||||||
@@ -62,8 +61,6 @@ export function MessagesInboxScreen(props: Props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function MessagesInboxScreenInner({}: Props) {
|
export function MessagesInboxScreenInner({}: Props) {
|
||||||
const {gtTablet} = useBreakpoints()
|
|
||||||
|
|
||||||
const listConvosQuery = useListConvosQuery({status: 'request'})
|
const listConvosQuery = useListConvosQuery({status: 'request'})
|
||||||
const {data} = listConvosQuery
|
const {data} = listConvosQuery
|
||||||
|
|
||||||
@@ -94,21 +91,16 @@ export function MessagesInboxScreenInner({}: Props) {
|
|||||||
<Layout.Screen testID="messagesInboxScreen">
|
<Layout.Screen testID="messagesInboxScreen">
|
||||||
<Layout.Header.Outer>
|
<Layout.Header.Outer>
|
||||||
<Layout.Header.BackButton />
|
<Layout.Header.BackButton />
|
||||||
<Layout.Header.Content align={gtTablet ? 'left' : 'platform'}>
|
<Layout.Header.Content align="left">
|
||||||
<Layout.Header.TitleText>
|
<Layout.Header.TitleText>
|
||||||
<Trans>Chat requests</Trans>
|
<Trans>Chat requests</Trans>
|
||||||
</Layout.Header.TitleText>
|
</Layout.Header.TitleText>
|
||||||
</Layout.Header.Content>
|
</Layout.Header.Content>
|
||||||
{hasUnreadConvos && gtTablet ? (
|
{hasUnreadConvos ? <MarkAsReadHeaderButton /> : <Layout.Header.Slot />}
|
||||||
<MarkAsReadHeaderButton />
|
|
||||||
) : (
|
|
||||||
<Layout.Header.Slot />
|
|
||||||
)}
|
|
||||||
</Layout.Header.Outer>
|
</Layout.Header.Outer>
|
||||||
<RequestList
|
<RequestList
|
||||||
listConvosQuery={listConvosQuery}
|
listConvosQuery={listConvosQuery}
|
||||||
conversations={conversations}
|
conversations={conversations}
|
||||||
hasUnreadConvos={hasUnreadConvos}
|
|
||||||
/>
|
/>
|
||||||
</Layout.Screen>
|
</Layout.Screen>
|
||||||
)
|
)
|
||||||
@@ -117,14 +109,12 @@ export function MessagesInboxScreenInner({}: Props) {
|
|||||||
function RequestList({
|
function RequestList({
|
||||||
listConvosQuery,
|
listConvosQuery,
|
||||||
conversations,
|
conversations,
|
||||||
hasUnreadConvos,
|
|
||||||
}: {
|
}: {
|
||||||
listConvosQuery: UseInfiniteQueryResult<
|
listConvosQuery: UseInfiniteQueryResult<
|
||||||
InfiniteData<ChatBskyConvoListConvos.OutputSchema>,
|
InfiniteData<ChatBskyConvoListConvos.OutputSchema>,
|
||||||
Error
|
Error
|
||||||
>
|
>
|
||||||
conversations: ChatBskyConvoDefs.ConvoView[]
|
conversations: ChatBskyConvoDefs.ConvoView[]
|
||||||
hasUnreadConvos: boolean
|
|
||||||
}) {
|
}) {
|
||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
@@ -285,7 +275,6 @@ function RequestList({
|
|||||||
desktopFixedHeight
|
desktopFixedHeight
|
||||||
sideBorders={false}
|
sideBorders={false}
|
||||||
/>
|
/>
|
||||||
{hasUnreadConvos && <MarkAllReadFAB />}
|
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -298,34 +287,6 @@ function renderItem({item}: {item: ChatBskyConvoDefs.ConvoView}) {
|
|||||||
return <RequestListItem convo={item} />
|
return <RequestListItem convo={item} />
|
||||||
}
|
}
|
||||||
|
|
||||||
function MarkAllReadFAB() {
|
|
||||||
const {t: l} = useLingui()
|
|
||||||
const t = useTheme()
|
|
||||||
const {mutate: markAllRead} = useUpdateAllRead('request', {
|
|
||||||
onMutate: () => {
|
|
||||||
Toast.show(l`Marked all as read`, {
|
|
||||||
type: 'success',
|
|
||||||
})
|
|
||||||
},
|
|
||||||
onError: () => {
|
|
||||||
Toast.show(l`Failed to mark all requests as read`, {
|
|
||||||
type: 'error',
|
|
||||||
})
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FAB
|
|
||||||
testID="markAllAsReadFAB"
|
|
||||||
onPress={() => markAllRead()}
|
|
||||||
icon={<CheckIcon size="lg" fill={t.palette.white} />}
|
|
||||||
accessibilityRole="button"
|
|
||||||
accessibilityLabel={l`Mark all as read`}
|
|
||||||
accessibilityHint=""
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function MarkAsReadHeaderButton() {
|
function MarkAsReadHeaderButton() {
|
||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const {mutate: markAllRead} = useUpdateAllRead('request', {
|
const {mutate: markAllRead} = useUpdateAllRead('request', {
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ function DirectChatItem({
|
|||||||
}) {
|
}) {
|
||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const profile = useProfileShadow(convo.primaryMember)
|
const profile = useProfileShadow(convo.primaryMember)
|
||||||
const {isWithinSplitView} = useIsWithinSplitView()
|
const {isWithinLeftPanel} = useIsWithinSplitView()
|
||||||
|
|
||||||
const moderation = useMemo(
|
const moderation = useMemo(
|
||||||
() => moderateProfile(profile, moderationOpts),
|
() => moderateProfile(profile, moderationOpts),
|
||||||
@@ -140,7 +140,7 @@ function DirectChatItem({
|
|||||||
avatar={
|
avatar={
|
||||||
<PreviewableUserAvatar
|
<PreviewableUserAvatar
|
||||||
profile={profile}
|
profile={profile}
|
||||||
size={isWithinSplitView ? 48 : 52}
|
size={isWithinLeftPanel ? 48 : 52}
|
||||||
moderation={moderation.ui('avatar')}
|
moderation={moderation.ui('avatar')}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ function DirectChatItem({
|
|||||||
isBlockedAccount={moderation.blocked}
|
isBlockedAccount={moderation.blocked}
|
||||||
showProfileBadges
|
showProfileBadges
|
||||||
postAlerts={
|
postAlerts={
|
||||||
isWithinSplitView ? null : (
|
isWithinLeftPanel ? null : (
|
||||||
<PostAlerts
|
<PostAlerts
|
||||||
modui={moderation.ui('contentList')}
|
modui={moderation.ui('contentList')}
|
||||||
size="sm"
|
size="sm"
|
||||||
@@ -189,7 +189,7 @@ function GroupChatItem({
|
|||||||
}) {
|
}) {
|
||||||
const {t: l} = useLingui()
|
const {t: l} = useLingui()
|
||||||
const groupOwner = useMaybeProfileShadow(convo.primaryMember)
|
const groupOwner = useMaybeProfileShadow(convo.primaryMember)
|
||||||
const {isWithinSplitView} = useIsWithinSplitView()
|
const {isWithinLeftPanel} = useIsWithinSplitView()
|
||||||
|
|
||||||
const moderation = useMemo(
|
const moderation = useMemo(
|
||||||
() =>
|
() =>
|
||||||
@@ -205,7 +205,7 @@ function GroupChatItem({
|
|||||||
avatar={
|
avatar={
|
||||||
<AvatarBubbles
|
<AvatarBubbles
|
||||||
profiles={convo.members}
|
profiles={convo.members}
|
||||||
size={isWithinSplitView ? 48 : 52}
|
size={isWithinLeftPanel ? 48 : 52}
|
||||||
moderationOpts={moderationOpts}
|
moderationOpts={moderationOpts}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
@@ -278,7 +278,7 @@ function BaseChatItem({
|
|||||||
const leaveConvoControl = useDialogControl()
|
const leaveConvoControl = useDialogControl()
|
||||||
const {mutate: markAsRead} = useMarkAsReadMutation()
|
const {mutate: markAsRead} = useMarkAsReadMutation()
|
||||||
const {gtMobile} = useBreakpoints()
|
const {gtMobile} = useBreakpoints()
|
||||||
const {isWithinSplitView} = useIsWithinSplitView()
|
const {isWithinLeftPanel} = useIsWithinSplitView()
|
||||||
|
|
||||||
const playHaptic = useHaptics()
|
const playHaptic = useHaptics()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
@@ -458,7 +458,7 @@ function BaseChatItem({
|
|||||||
leftFirst: deleteAction,
|
leftFirst: deleteAction,
|
||||||
}
|
}
|
||||||
|
|
||||||
const avatarSize = isWithinSplitView ? 48 : 52
|
const avatarSize = isWithinLeftPanel ? 48 : 52
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ChatListItemPortal.Provider>
|
<ChatListItemPortal.Provider>
|
||||||
@@ -469,7 +469,7 @@ function BaseChatItem({
|
|||||||
// @ts-expect-error web only
|
// @ts-expect-error web only
|
||||||
onFocus={onFocus}
|
onFocus={onFocus}
|
||||||
onBlur={onMouseLeave}
|
onBlur={onMouseLeave}
|
||||||
style={[a.relative, t.atoms.bg, isWithinSplitView && a.mx_sm]}>
|
style={[a.relative, t.atoms.bg, isWithinLeftPanel && a.mx_sm]}>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
a.z_10,
|
a.z_10,
|
||||||
@@ -512,7 +512,7 @@ function BaseChatItem({
|
|||||||
a.px_lg,
|
a.px_lg,
|
||||||
a.py_md,
|
a.py_md,
|
||||||
a.gap_md,
|
a.gap_md,
|
||||||
isWithinSplitView && a.rounded_sm,
|
isWithinLeftPanel && a.rounded_sm,
|
||||||
{
|
{
|
||||||
backgroundColor: hasUnread
|
backgroundColor: hasUnread
|
||||||
? t.palette.primary_25
|
? t.palette.primary_25
|
||||||
|
|||||||
Reference in New Issue
Block a user