From 89525d3e16f02d5c478ba975f3ee714a5e58ed13 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Wed, 14 Feb 2024 10:15:26 -0800 Subject: [PATCH] Support Enter shortcut in findBy helpers --- ts/components/LeftPane.tsx | 4 ++ .../LeftPaneFindByPhoneNumberHelper.tsx | 70 ++++++++++++------- .../leftPane/LeftPaneFindByUsernameHelper.tsx | 68 +++++++++++------- ts/components/leftPane/LeftPaneHelper.tsx | 4 +- 4 files changed, 92 insertions(+), 54 deletions(-) diff --git a/ts/components/LeftPane.tsx b/ts/components/LeftPane.tsx index 74b304b1104a..47768b98d358 100644 --- a/ts/components/LeftPane.tsx +++ b/ts/components/LeftPane.tsx @@ -714,6 +714,10 @@ export function LeftPane({ updateSearchTerm, onChangeComposeSelectedRegion: setComposeSelectedRegion, showConversation, + lookupConversationWithoutServiceId, + showUserNotFoundModal, + setIsFetchingUUID, + showInbox, })} )} diff --git a/ts/components/leftPane/LeftPaneFindByPhoneNumberHelper.tsx b/ts/components/leftPane/LeftPaneFindByPhoneNumberHelper.tsx index e963a4a3e4e7..d066a235bb4b 100644 --- a/ts/components/leftPane/LeftPaneFindByPhoneNumberHelper.tsx +++ b/ts/components/leftPane/LeftPaneFindByPhoneNumberHelper.tsx @@ -15,6 +15,7 @@ import { parseAndFormatPhoneNumber } from '../../util/libphonenumberInstance'; import type { UUIDFetchStateType } from '../../util/uuidFetchState'; import type { CountryDataType } from '../../util/getCountryData'; import { isFetchingByE164 } from '../../util/uuidFetchState'; +import { drop } from '../../util/drop'; import type { LookupConversationWithoutServiceIdActionsType } from '../../util/lookupConversationWithoutServiceId'; import { Spinner } from '../Spinner'; import { Button } from '../Button'; @@ -28,6 +29,12 @@ export type LeftPaneFindByPhoneNumberPropsType = { countries: ReadonlyArray; }; +type DoLookupActionsType = Readonly<{ + showInbox: () => void; + showConversation: ShowConversationType; +}> & + LookupConversationWithoutServiceIdActionsType; + export class LeftPaneFindByPhoneNumberHelper extends LeftPaneHelper { private readonly searchTerm: string; @@ -100,13 +107,15 @@ export class LeftPaneFindByPhoneNumberHelper extends LeftPaneHelper ) => unknown; onChangeComposeSelectedRegion: (newRegion: string) => void; - }>): ReactChild { + }> & + DoLookupActionsType): ReactChild { const placeholder = i18n( 'icu:LeftPaneFindByHelper__placeholder--findByPhoneNumber' ); @@ -129,6 +138,11 @@ export class LeftPaneFindByPhoneNumberHelper extends LeftPaneHelper { + if (ev.key === 'Enter') { + drop(this.doLookup(lookupActions)); + } + }} /> ); @@ -136,38 +150,15 @@ export class LeftPaneFindByPhoneNumberHelper extends LeftPaneHelper void; - showConversation: ShowConversationType; }> & - LookupConversationWithoutServiceIdActionsType): ReactChild { + DoLookupActionsType): ReactChild { return (