diff --git a/apps/mobile/src/modules/messages/components/MultisigInvitationDetailContent/useMultisigInvitationDetailContent.ts b/apps/mobile/src/modules/messages/components/MultisigInvitationDetailContent/useMultisigInvitationDetailContent.ts index 4b0209e1e..28a142009 100644 --- a/apps/mobile/src/modules/messages/components/MultisigInvitationDetailContent/useMultisigInvitationDetailContent.ts +++ b/apps/mobile/src/modules/messages/components/MultisigInvitationDetailContent/useMultisigInvitationDetailContent.ts @@ -15,7 +15,6 @@ import { useNetwork } from '@perawallet/wallet-core-blockchain' import { useDeviceID } from '@perawallet/wallet-core-device' import { useDeleteMultisigInvitationMutation } from '@perawallet/wallet-core-messages' import { useAllAccounts } from '@perawallet/wallet-core-accounts' -import { useAppNavigation } from '@hooks/useAppNavigation' import { useLanguage } from '@hooks/useLanguage' import { useToast } from '@hooks/useToast' import type { MultisigInvitationParam } from '../../routes/types' @@ -40,7 +39,6 @@ export const useMultisigInvitationDetailContent = ({ onIgnored, onAccepted, }: UseMultisigInvitationDetailContentParams): UseMultisigInvitationDetailContentResult => { - const { push } = useAppNavigation() const { t } = useLanguage() const { errorToast } = useToast() const { network } = useNetwork() @@ -96,20 +94,12 @@ export const useMultisigInvitationDetailContent = ({ t, ]) - const handleAccept = useCallback(() => { - onAccepted() - push('Messages', { - screen: 'MultisigInvitationName', - params: { invitation: renderedInvitation }, - }) - }, [push, renderedInvitation, onAccepted]) - return { renderedInvitation, totalParticipants, isIgnoring, isUserIncluded, handleIgnore, - handleAccept, + handleAccept: onAccepted, } } diff --git a/apps/mobile/src/modules/messages/screens/InboxScreen/__tests__/useInboxScreen.spec.ts b/apps/mobile/src/modules/messages/screens/InboxScreen/__tests__/useInboxScreen.spec.ts index ec421fdde..9338fa519 100644 --- a/apps/mobile/src/modules/messages/screens/InboxScreen/__tests__/useInboxScreen.spec.ts +++ b/apps/mobile/src/modules/messages/screens/InboxScreen/__tests__/useInboxScreen.spec.ts @@ -145,11 +145,81 @@ describe('useInboxScreen', () => { expect(mockRequestBottomSheet).toHaveBeenCalledTimes(1) const arg = mockRequestBottomSheet.mock.calls[0][0] expect(arg.options).toEqual({ - size: 'lg', + size: 'auto', enablePanDownToClose: true, }) }) + it('navigates to MultisigInvitationName when the invitation sheet resolves "accept"', async () => { + mockRequestBottomSheet.mockResolvedValueOnce('accept') + const createdAt = new Date('2025-01-15T00:00:00.000Z') + const importItem = { + type: 'multisig_import' as const, + data: { + customId: 'msig-1', + createdAt, + address: 'MSIG_ADDR1', + version: 1, + threshold: 2, + participantAddresses: ['ADDR1', 'ADDR2'], + }, + createdAt, + } + + const { result } = renderHook(() => useInboxScreen()) + + await act(async () => { + result.current.handleInboxItemPress( + importItem as unknown as Parameters< + typeof result.current.handleInboxItemPress + >[0], + ) + }) + + expect(mockPush).toHaveBeenCalledWith('Messages', { + screen: 'MultisigInvitationName', + params: { + invitation: { + customId: 'msig-1', + createdAt: createdAt.toISOString(), + address: 'MSIG_ADDR1', + version: 1, + threshold: 2, + participantAddresses: ['ADDR1', 'ADDR2'], + }, + }, + }) + }) + + it('does not navigate when the invitation sheet resolves "decline"', async () => { + mockRequestBottomSheet.mockResolvedValueOnce('decline') + const createdAt = new Date('2025-01-15T00:00:00.000Z') + const importItem = { + type: 'multisig_import' as const, + data: { + customId: 'msig-1', + createdAt, + address: 'MSIG_ADDR1', + version: 1, + threshold: 2, + participantAddresses: ['ADDR1', 'ADDR2'], + }, + createdAt, + } + + const { result } = renderHook(() => useInboxScreen()) + + await act(async () => { + result.current.handleInboxItemPress( + importItem as unknown as Parameters< + typeof result.current.handleInboxItemPress + >[0], + ) + }) + + expect(mockPush).not.toHaveBeenCalled() + }) + it('handleInboxItemPress delegates multisig_sign to the multisig sign-tap handler', () => { const signItem = { type: 'multisig_sign' as const, diff --git a/apps/mobile/src/modules/messages/screens/InboxScreen/useInboxScreen.tsx b/apps/mobile/src/modules/messages/screens/InboxScreen/useInboxScreen.tsx index 43fbe3873..46d2fef6a 100644 --- a/apps/mobile/src/modules/messages/screens/InboxScreen/useInboxScreen.tsx +++ b/apps/mobile/src/modules/messages/screens/InboxScreen/useInboxScreen.tsx @@ -74,14 +74,26 @@ export const useInboxScreen = (): UseInboxScreenResult => { const openInvitationDetail = useCallback( async (invitation: MultisigInvitationParam) => { - await requestBottomSheet({ - contents: ( - - ), - options: { size: 'lg', enablePanDownToClose: true }, - }) + const result = + await requestBottomSheet( + { + contents: ( + + ), + options: { size: 'auto', enablePanDownToClose: true }, + }, + ) + + if (result === 'accept') { + push('Messages', { + screen: 'MultisigInvitationName', + params: { invitation }, + }) + } }, - [requestBottomSheet], + [requestBottomSheet, push], ) const handleInboxItemPress = useCallback(