background.ts: Introduce types for redux initialState

This commit is contained in:
Scott Nonnenberg 2022-02-23 10:48:40 -08:00 committed by GitHub
parent 3673b6d101
commit 4763831d3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 315 additions and 238 deletions

View file

@ -40,15 +40,10 @@ import type {
StartCallType,
} from '../state/ducks/calling';
import type { LocalizerType, ThemeType } from '../types/Util';
import type { UUIDStringType } from '../types/UUID';
import { missingCaseError } from '../util/missingCaseError';
const GROUP_CALL_RING_DURATION = 60 * 1000;
type MeType = ConversationType & {
uuid: UUIDStringType;
};
export type PropsType = {
activeCall?: ActiveCallType;
availableCameras: Array<MediaDeviceInfo>;
@ -83,7 +78,7 @@ export type PropsType = {
declineCall: (_: DeclineCallType) => void;
i18n: LocalizerType;
isGroupCallOutboundRingEnabled: boolean;
me: MeType;
me: ConversationType;
notifyForCall: (title: string, isVideoCall: boolean) => unknown;
openSystemPreferencesAction: () => unknown;
playRingtone: () => unknown;

View file

@ -150,14 +150,14 @@ const createProps = (
getPresentingSources: action('get-presenting-sources'),
hangUpActiveCall: action('hang-up'),
i18n,
me: {
me: getDefaultConversation({
color: AvatarColors[1],
id: '6146087e-f7ef-457e-9a8d-47df1fdd6b25',
name: 'Morty Smith',
profileName: 'Morty Smith',
title: 'Morty Smith',
uuid: '3c134598-eecb-42ab-9ad3-2b0873f771b2',
},
}),
openSystemPreferencesAction: action('open-system-preferences-action'),
setGroupCallVideoRequest: action('set-group-call-video-request'),
setLocalAudio: action('set-local-audio'),

View file

@ -28,7 +28,6 @@ import {
GroupCallConnectionState,
GroupCallJoinState,
} from '../types/Calling';
import type { AvatarColorType } from '../types/Colors';
import { AvatarColors } from '../types/Colors';
import type { ConversationType } from '../state/ducks/conversations';
import { CallingToastManager } from './CallingToastManager';
@ -37,7 +36,6 @@ import { GroupCallRemoteParticipants } from './GroupCallRemoteParticipants';
import type { LocalizerType } from '../types/Util';
import { NeedsScreenRecordingPermissionsModal } from './NeedsScreenRecordingPermissionsModal';
import { missingCaseError } from '../util/missingCaseError';
import type { UUIDStringType } from '../types/UUID';
import * as KeyboardLayout from '../services/keyboardLayout';
import { useActivateSpeakerViewOnPresenting } from '../hooks/useActivateSpeakerViewOnPresenting';
@ -49,16 +47,7 @@ export type PropsType = {
hangUpActiveCall: () => void;
i18n: LocalizerType;
joinedAt?: number;
me: {
avatarPath?: string;
color?: AvatarColorType;
id: string;
name?: string;
phoneNumber?: string;
profileName?: string;
title: string;
uuid: UUIDStringType;
};
me: ConversationType;
openSystemPreferencesAction: () => unknown;
setGroupCallVideoRequest: (_: Array<GroupCallVideoRequest>) => void;
setLocalAudio: (_: SetLocalAudioType) => void;

View file

@ -61,11 +61,13 @@ const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => {
isGroupCall,
isGroupCallOutboundRingEnabled: true,
isCallFull: boolean('isCallFull', overrideProps.isCallFull || false),
me: overrideProps.me || {
color: AvatarColors[0],
id: UUID.generate().toString(),
uuid: UUID.generate().toString(),
},
me:
overrideProps.me ||
getDefaultConversation({
color: AvatarColors[0],
id: UUID.generate().toString(),
uuid: UUID.generate().toString(),
}),
onCallCanceled: action('on-call-canceled'),
onJoinCall: action('on-join-call'),
outgoingRing: boolean('outgoingRing', Boolean(overrideProps.outgoingRing)),
@ -105,12 +107,12 @@ story.add('No Camera, no avatar', () => {
story.add('No Camera, local avatar', () => {
const props = createProps({
availableCameras: [],
me: {
me: getDefaultConversation({
avatarPath: '/fixtures/kitten-4-112-112.jpg',
color: AvatarColors[0],
id: UUID.generate().toString(),
uuid: UUID.generate().toString(),
},
}),
});
return <CallingLobby {...props} />;
});
@ -146,10 +148,10 @@ story.add('Group Call - 1 peeked participant (self)', () => {
const uuid = UUID.generate().toString();
const props = createProps({
isGroupCall: true,
me: {
me: getDefaultConversation({
id: UUID.generate().toString(),
uuid,
},
}),
peekedParticipants: [fakePeekedParticipant({ title: 'Ash', uuid })],
});
return <CallingLobby {...props} />;

View file

@ -19,9 +19,7 @@ import {
CallingLobbyJoinButton,
CallingLobbyJoinButtonVariant,
} from './CallingLobbyJoinButton';
import type { AvatarColorType } from '../types/Colors';
import type { LocalizerType } from '../types/Util';
import type { UUIDStringType } from '../types/UUID';
import { useIsOnline } from '../hooks/useIsOnline';
import * as KeyboardLayout from '../services/keyboardLayout';
import type { ConversationType } from '../state/ducks/conversations';
@ -51,12 +49,7 @@ export type PropsType = {
isGroupCall: boolean;
isGroupCallOutboundRingEnabled: boolean;
isCallFull?: boolean;
me: {
avatarPath?: string;
id: string;
color?: AvatarColorType;
uuid: UUIDStringType;
};
me: Readonly<Pick<ConversationType, 'avatarPath' | 'color' | 'id' | 'uuid'>>;
onCallCanceled: () => void;
onJoinCall: () => void;
outgoingRing: boolean;

View file

@ -1,4 +1,4 @@
// Copyright 2020-2021 Signal Messenger, LLC
// Copyright 2020-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
/* eslint-disable react/no-array-index-key */
@ -24,7 +24,7 @@ type ParticipantType = ConversationType & {
export type PropsType = {
readonly i18n: LocalizerType;
readonly onClose: () => void;
readonly ourUuid: string;
readonly ourUuid: string | undefined;
readonly participants: Array<ParticipantType>;
};
@ -113,7 +113,7 @@ export const CallingParticipantsList = React.memo(
sharedGroupNames={participant.sharedGroupNames}
size={32}
/>
{participant.uuid === ourUuid ? (
{ourUuid && participant.uuid === ourUuid ? (
<span className="module-calling-participants-list__name">
{i18n('you')}
</span>

View file

@ -88,7 +88,7 @@ export type PropsType = {
preferredWidthFromStorage: number;
selectedConversationId: undefined | string;
selectedMessageId: undefined | string;
regionCode: string;
regionCode: string | undefined;
challengeStatus: 'idle' | 'required' | 'pending';
setChallengeStatus: (status: 'idle') => void;
crashReportCount: number;

View file

@ -1,4 +1,4 @@
// Copyright 2020-2021 Signal Messenger, LLC
// Copyright 2020-2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { ReactElement } from 'react';
@ -22,7 +22,7 @@ import { Modal } from '../Modal';
export type PropsDataType = {
groupName?: string;
ourUuid: UUIDStringType;
ourUuid?: UUIDStringType;
change: GroupV2ChangeType;
};

View file

@ -24,7 +24,7 @@ export type LeftPaneComposePropsType = {
composeContacts: ReadonlyArray<ContactListItemConversationType>;
composeGroups: ReadonlyArray<ConversationListItemPropsType>;
regionCode: string;
regionCode: string | undefined;
searchTerm: string;
isFetchingUsername: boolean;
isUsernamesEnabled: boolean;
@ -355,7 +355,7 @@ function focusRef(el: HTMLElement | null) {
function parsePhoneNumber(
str: string,
regionCode: string
regionCode: string | undefined
): undefined | PhoneNumber {
let result: PhoneNumber;
try {