Allow adding to a group by phone number

This commit is contained in:
Fedor Indutny 2022-04-04 17:38:22 -07:00 committed by GitHub
parent 76a1a805ef
commit 9568d5792e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 1842 additions and 693 deletions

View file

@ -2,12 +2,13 @@
// SPDX-License-Identifier: AGPL-3.0-only
import type { FunctionComponent } from 'react';
import React from 'react';
import { noop } from 'lodash';
import React, { useCallback } from 'react';
import { BaseConversationListItem } from './BaseConversationListItem';
import type { LocalizerType } from '../../types/Util';
import { lookupConversationWithoutUuid } from '../../util/lookupConversationWithoutUuid';
import type { LookupConversationWithoutUuidActionsType } from '../../util/lookupConversationWithoutUuid';
type PropsData = {
username: string;
@ -16,23 +17,42 @@ type PropsData = {
type PropsHousekeeping = {
i18n: LocalizerType;
onClick: (username: string) => void;
};
showConversation: (conversationId: string) => void;
} & LookupConversationWithoutUuidActionsType;
export type Props = PropsData & PropsHousekeeping;
export const UsernameSearchResultListItem: FunctionComponent<Props> = ({
i18n,
isFetchingUsername,
onClick,
username,
showUserNotFoundModal,
setIsFetchingUUID,
showConversation,
}) => {
const usernameText = i18n('at-username', { username });
const boundOnClick = isFetchingUsername
? noop
: () => {
onClick(username);
};
const boundOnClick = useCallback(async () => {
if (isFetchingUsername) {
return;
}
const conversationId = await lookupConversationWithoutUuid({
showUserNotFoundModal,
setIsFetchingUUID,
type: 'username',
username,
});
if (conversationId !== undefined) {
showConversation(conversationId);
}
}, [
username,
showUserNotFoundModal,
setIsFetchingUUID,
showConversation,
isFetchingUsername,
]);
return (
<BaseConversationListItem