From feff61a031ec84e8eee5baf7ff85deb84eb67464 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Sat, 13 Jun 2026 15:23:28 +0300 Subject: [PATCH] Add long-press menu to Chat tab for marking all as read (#10890) --- src/view/shell/bottom-bar/BottomBar.tsx | 97 ++++++++++++++++++++----- 1 file changed, 77 insertions(+), 20 deletions(-) diff --git a/src/view/shell/bottom-bar/BottomBar.tsx b/src/view/shell/bottom-bar/BottomBar.tsx index 605542749e..8650e99b89 100644 --- a/src/view/shell/bottom-bar/BottomBar.tsx +++ b/src/view/shell/bottom-bar/BottomBar.tsx @@ -2,9 +2,8 @@ import {type JSX, useCallback} from 'react' import {type GestureResponderEvent, View} from 'react-native' import Animated from 'react-native-reanimated' import {useSafeAreaInsets} from 'react-native-safe-area-context' -import {msg, plural} from '@lingui/core/macro' -import {useLingui} from '@lingui/react' -import {Trans} from '@lingui/react/macro' +import {plural} from '@lingui/core/macro' +import {Trans, useLingui} from '@lingui/react/macro' import {type BottomTabBarProps} from '@react-navigation/bottom-tabs' import {StackActions} from '@react-navigation/native' @@ -20,6 +19,7 @@ import {getTabState, TabState} from '#/lib/routes/helpers' import {type SharedNavTab, TAB_TO_NAV_ITEM} from '#/lib/routes/tab-to-nav-item' import {emitSoftReset} from '#/state/events' import {useUnreadMessageCount} from '#/state/queries/messages/list-conversations' +import {useUpdateAllRead} from '#/state/queries/messages/update-all-read' import {useUnreadNotifications} from '#/state/queries/notifications/unread' import {useProfileQuery} from '#/state/queries/profile' import {useSession} from '#/state/session' @@ -37,10 +37,12 @@ import { Bell_Filled_Corner0_Rounded as BellFilled, Bell_Stroke2_Corner0_Rounded as Bell, } from '#/components/icons/Bell' +import {CircleCheck_Stroke2_Corner0_Rounded as CircleCheckIcon} from '#/components/icons/CircleCheck' import { HomeOpen_Filled_Corner0_Rounded as HomeFilled, HomeOpen_Stoke2_Corner0_Rounded as Home, } from '#/components/icons/HomeOpen' +import {Inbox_Stroke2_Corner2_Rounded as InboxIcon} from '#/components/icons/Inbox' import { MagnifyingGlass_Filled_Stroke2_Corner0_Rounded as MagnifyingGlassFilled, MagnifyingGlass_Stroke2_Corner0_Rounded as MagnifyingGlass, @@ -49,6 +51,8 @@ import { Message_Stroke2_Corner0_Rounded as Message, Message_Stroke2_Corner0_Rounded_Filled as MessageFilled, } from '#/components/icons/Message' +import * as Menu from '#/components/Menu' +import * as Toast from '#/components/Toast' import {Text} from '#/components/Typography' import {useAgeAssurance} from '#/ageAssurance' import {useAnalytics} from '#/analytics' @@ -59,7 +63,7 @@ import {styles} from './BottomBarStyles' export function BottomBar({navigation}: BottomTabBarProps) { const {hasSession, currentAccount} = useSession() const t = useTheme() - const {_} = useLingui() + const {t: l} = useLingui() const ax = useAnalytics() const safeAreaInsets = useSafeAreaInsets() const {footerHeight} = useShellLayout() @@ -74,6 +78,7 @@ export function BottomBar({navigation}: BottomTabBarProps) { const closeAllActiveElements = useCloseAllActiveElements() const dedupe = useDedupe() const accountSwitchControl = useDialogControl() + const messagesMenuControl = Menu.useMenuControl() const playHaptic = useHaptics() const hideBorder = useHideBottomBarBorder() const iconWidth = 28 @@ -142,6 +147,12 @@ export function BottomBar({navigation}: BottomTabBarProps) { accountSwitchControl.open() }, [accountSwitchControl, playHaptic]) + const onLongPressMessages = useCallback(() => { + if (aa.flags.chatDisabled) return + playHaptic() + messagesMenuControl.open() + }, [aa.flags.chatDisabled, messagesMenuControl, playHaptic]) + const [demoMode] = useDemoMode() const {isActive: live} = useActorStatus(profile) const isLabeler = profile?.associated?.labeler @@ -149,7 +160,7 @@ export function BottomBar({navigation}: BottomTabBarProps) { return ( <> - + 0 - ? _( - plural(numUnreadMessages.numUnread ?? 0, { + ? l({ + message: plural(numUnreadMessages.numUnread ?? 0, { one: '# unread item', other: '# unread items', }), - ) + }) : '' } /> @@ -258,16 +270,16 @@ export function BottomBar({navigation}: BottomTabBarProps) { notificationCount={numUnreadNotifications} accessible={true} accessibilityRole="tab" - accessibilityLabel={_(msg`Notifications`)} + accessibilityLabel={l`Notifications`} accessibilityHint={ numUnreadNotifications === '' ? '' - : _( - plural(numUnreadNotifications ?? 0, { + : l({ + message: plural(numUnreadNotifications ?? 0, { one: '# unread item', other: '# unread items', }), - ) + }) } /> @@ -330,9 +342,8 @@ export function BottomBar({navigation}: BottomTabBarProps) {