Introduce Service Id Types

Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
Fedor Indutny 2023-08-10 18:43:33 +02:00 committed by Jamie Kyle
parent 414c0a58d3
commit 366b875fd2
269 changed files with 5832 additions and 5550 deletions

View file

@ -5,6 +5,7 @@ import type { ReactNode, FunctionComponent } from 'react';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import classNames from 'classnames';
import { isBoolean, isNumber } from 'lodash';
import { v4 as generateUuid } from 'uuid';
import { Avatar, AvatarSize } from '../Avatar';
import type { BadgeType } from '../../badges/types';
@ -16,7 +17,6 @@ import { Spinner } from '../Spinner';
import { Time } from '../Time';
import { formatDateTimeShort } from '../../util/timestamp';
import * as durations from '../../util/durations';
import { UUID } from '../../types/UUID';
const BASE_CLASS_NAME =
'module-conversation-list__item--contact-or-conversation';
@ -113,7 +113,7 @@ export const BaseConversationListItem: FunctionComponent<PropsType> =
} = props;
const identifier = id ? cleanId(id) : undefined;
const htmlId = useMemo(() => UUID.generate().toString(), []);
const htmlId = useMemo(() => generateUuid(), []);
const testId = overrideTestId || groupId || uuid;
const isUnread = isConversationUnread({ markedUnread, unreadCount });

View file

@ -4,7 +4,7 @@
import React from 'react';
import type { ConversationType } from '../../state/ducks/conversations';
import type { LocalizerType } from '../../types/Util';
import type { UUIDStringType } from '../../types/UUID';
import type { AciString } from '../../types/ServiceId';
import { Avatar, AvatarSize } from '../Avatar';
import { ListTile } from '../ListTile';
import { UserText } from '../UserText';
@ -21,7 +21,7 @@ export type GroupListItemConversationType = Pick<
disabledReason: DisabledReason | undefined;
membersCount: number;
memberships: ReadonlyArray<{
uuid: UUIDStringType;
uuid: AciString;
isAdmin: boolean;
}>;
};

View file

@ -13,6 +13,11 @@ import type { PropsType } from './MessageSearchResult';
import { MessageSearchResult } from './MessageSearchResult';
import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation';
import { BodyRange } from '../../types/BodyRange';
import { generateAci } from '../../types/ServiceId';
const SERVICE_ID_1 = generateAci();
const SERVICE_ID_2 = generateAci();
const SERVICE_ID_3 = generateAci();
const i18n = setupI18n('en', enMessages);
@ -198,14 +203,14 @@ export function Mention(): JSX.Element {
bodyRanges: [
{
length: 1,
mentionUuid: '7d007e95-771d-43ad-9191-eaa86c773cb8',
mentionUuid: SERVICE_ID_3,
replacementText: 'Shoe',
conversationID: 'x',
start: 113,
},
{
length: 1,
mentionUuid: '7d007e95-771d-43ad-9191-eaa86c773cb8',
mentionUuid: SERVICE_ID_3,
replacementText: 'Shoe',
conversationID: 'x',
start: 237,
@ -230,7 +235,7 @@ export function MentionRegexp(): JSX.Element {
bodyRanges: [
{
length: 1,
mentionUuid: '7d007e95-771d-43ad-9191-eaa86c773cb8',
mentionUuid: SERVICE_ID_3,
replacementText: 'RegExp',
conversationID: 'x',
start: 0,
@ -255,7 +260,7 @@ export function MentionNoMatches(): JSX.Element {
bodyRanges: [
{
length: 1,
mentionUuid: '7d007e95-771d-43ad-9191-eaa86c773cb8',
mentionUuid: SERVICE_ID_3,
replacementText: 'Neo',
conversationID: 'x',
start: 0,
@ -279,14 +284,14 @@ export const _MentionNoMatches = (): JSX.Element => {
bodyRanges: [
{
length: 1,
mentionUuid: '7d007e95-771d-43ad-9191-eaa86c773cb8',
mentionUuid: SERVICE_ID_3,
replacementText: 'Shoe',
conversationID: 'x',
start: 113,
},
{
length: 1,
mentionUuid: '7d007e95-771d-43ad-9191-eaa86c773cb8',
mentionUuid: SERVICE_ID_3,
replacementText: 'Shoe',
conversationID: 'x',
start: 237,
@ -311,14 +316,14 @@ export function DoubleMention(): JSX.Element {
bodyRanges: [
{
length: 1,
mentionUuid: '9eb2eb65-992a-4909-a2a5-18c56bd7648f',
mentionUuid: SERVICE_ID_2,
replacementText: 'Alice',
conversationID: 'x',
start: 4,
},
{
length: 1,
mentionUuid: '755ec61b-1590-48da-b003-3e57b2b54448',
mentionUuid: SERVICE_ID_1,
replacementText: 'Bob',
conversationID: 'x',
start: 6,

View file

@ -10,7 +10,7 @@ import { SPINNER_CLASS_NAME } from './BaseConversationListItem';
import type { ParsedE164Type } from '../../util/libphonenumberInstance';
import type { LocalizerType, ThemeType } from '../../types/Util';
import { AvatarColors } from '../../types/Colors';
import type { LookupConversationWithoutUuidActionsType } from '../../util/lookupConversationWithoutUuid';
import type { LookupConversationWithoutServiceIdActionsType } from '../../util/lookupConversationWithoutServiceId';
import { ListTile } from '../ListTile';
import { Avatar, AvatarSize } from '../Avatar';
import { Spinner } from '../Spinner';
@ -26,7 +26,7 @@ type PropsHousekeepingType = {
i18n: LocalizerType;
theme: ThemeType;
toggleConversationInChooseMembers: (conversationId: string) => void;
} & LookupConversationWithoutUuidActionsType;
} & LookupConversationWithoutServiceIdActionsType;
type PropsType = PropsDataType & PropsHousekeepingType;
@ -36,7 +36,7 @@ export const PhoneNumberCheckbox: FunctionComponent<PropsType> = React.memo(
isChecked,
isFetching,
i18n,
lookupConversationWithoutUuid,
lookupConversationWithoutServiceId,
showUserNotFoundModal,
setIsFetchingUUID,
toggleConversationInChooseMembers,
@ -52,7 +52,7 @@ export const PhoneNumberCheckbox: FunctionComponent<PropsType> = React.memo(
return;
}
const conversationId = await lookupConversationWithoutUuid({
const conversationId = await lookupConversationWithoutServiceId({
showUserNotFoundModal,
setIsFetchingUUID,
@ -67,7 +67,7 @@ export const PhoneNumberCheckbox: FunctionComponent<PropsType> = React.memo(
}, [
isFetching,
toggleConversationInChooseMembers,
lookupConversationWithoutUuid,
lookupConversationWithoutServiceId,
showUserNotFoundModal,
setIsFetchingUUID,
setIsModalVisible,

View file

@ -12,7 +12,7 @@ import { Avatar, AvatarSize } from '../Avatar';
import { Spinner } from '../Spinner';
import type { ParsedE164Type } from '../../util/libphonenumberInstance';
import type { LookupConversationWithoutUuidActionsType } from '../../util/lookupConversationWithoutUuid';
import type { LookupConversationWithoutServiceIdActionsType } from '../../util/lookupConversationWithoutServiceId';
import type { LocalizerType } from '../../types/Util';
import type { ShowConversationType } from '../../state/ducks/conversations';
import { AvatarColors } from '../../types/Colors';
@ -25,7 +25,7 @@ type PropsData = {
type PropsHousekeeping = {
i18n: LocalizerType;
showConversation: ShowConversationType;
} & LookupConversationWithoutUuidActionsType;
} & LookupConversationWithoutServiceIdActionsType;
export type Props = PropsData & PropsHousekeeping;
@ -34,7 +34,7 @@ export const StartNewConversation: FunctionComponent<Props> = React.memo(
i18n,
phoneNumber,
isFetching,
lookupConversationWithoutUuid,
lookupConversationWithoutServiceId,
showUserNotFoundModal,
setIsFetchingUUID,
showConversation,
@ -49,7 +49,7 @@ export const StartNewConversation: FunctionComponent<Props> = React.memo(
if (isFetching) {
return;
}
const conversationId = await lookupConversationWithoutUuid({
const conversationId = await lookupConversationWithoutServiceId({
showUserNotFoundModal,
setIsFetchingUUID,
@ -63,7 +63,7 @@ export const StartNewConversation: FunctionComponent<Props> = React.memo(
}
}, [
showConversation,
lookupConversationWithoutUuid,
lookupConversationWithoutServiceId,
showUserNotFoundModal,
setIsFetchingUUID,
setIsModalVisible,

View file

@ -6,7 +6,7 @@ import type { FunctionComponent } from 'react';
import type { LocalizerType, ThemeType } from '../../types/Util';
import { AvatarColors } from '../../types/Colors';
import type { LookupConversationWithoutUuidActionsType } from '../../util/lookupConversationWithoutUuid';
import type { LookupConversationWithoutServiceIdActionsType } from '../../util/lookupConversationWithoutServiceId';
import { ListTile } from '../ListTile';
import { Avatar, AvatarSize } from '../Avatar';
import { Spinner } from '../Spinner';
@ -22,7 +22,7 @@ type PropsHousekeepingType = {
i18n: LocalizerType;
theme: ThemeType;
toggleConversationInChooseMembers: (conversationId: string) => void;
} & LookupConversationWithoutUuidActionsType;
} & LookupConversationWithoutServiceIdActionsType;
type PropsType = PropsDataType & PropsHousekeepingType;
@ -32,7 +32,7 @@ export const UsernameCheckbox: FunctionComponent<PropsType> = React.memo(
isChecked,
isFetching,
i18n,
lookupConversationWithoutUuid,
lookupConversationWithoutServiceId,
showUserNotFoundModal,
setIsFetchingUUID,
toggleConversationInChooseMembers,
@ -42,7 +42,7 @@ export const UsernameCheckbox: FunctionComponent<PropsType> = React.memo(
return;
}
const conversationId = await lookupConversationWithoutUuid({
const conversationId = await lookupConversationWithoutServiceId({
showUserNotFoundModal,
setIsFetchingUUID,
@ -56,7 +56,7 @@ export const UsernameCheckbox: FunctionComponent<PropsType> = React.memo(
}, [
isFetching,
toggleConversationInChooseMembers,
lookupConversationWithoutUuid,
lookupConversationWithoutServiceId,
showUserNotFoundModal,
setIsFetchingUUID,
username,

View file

@ -9,7 +9,7 @@ import { Avatar, AvatarSize } from '../Avatar';
import { Spinner } from '../Spinner';
import type { LocalizerType } from '../../types/Util';
import type { LookupConversationWithoutUuidActionsType } from '../../util/lookupConversationWithoutUuid';
import type { LookupConversationWithoutServiceIdActionsType } from '../../util/lookupConversationWithoutServiceId';
import type { ShowConversationType } from '../../state/ducks/conversations';
type PropsData = {
@ -20,14 +20,14 @@ type PropsData = {
type PropsHousekeeping = {
i18n: LocalizerType;
showConversation: ShowConversationType;
} & LookupConversationWithoutUuidActionsType;
} & LookupConversationWithoutServiceIdActionsType;
export type Props = PropsData & PropsHousekeeping;
export function UsernameSearchResultListItem({
i18n,
isFetchingUsername,
lookupConversationWithoutUuid,
lookupConversationWithoutServiceId,
username,
showUserNotFoundModal,
setIsFetchingUUID,
@ -37,7 +37,7 @@ export function UsernameSearchResultListItem({
if (isFetchingUsername) {
return;
}
const conversationId = await lookupConversationWithoutUuid({
const conversationId = await lookupConversationWithoutServiceId({
showUserNotFoundModal,
setIsFetchingUUID,
@ -50,7 +50,7 @@ export function UsernameSearchResultListItem({
}
}, [
isFetchingUsername,
lookupConversationWithoutUuid,
lookupConversationWithoutServiceId,
setIsFetchingUUID,
showConversation,
showUserNotFoundModal,