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

@ -17,7 +17,7 @@ import type {
ActiveCallType,
GroupCallRemoteParticipantType,
} from '../../types/Calling';
import type { UUIDStringType } from '../../types/UUID';
import type { AciString } from '../../types/ServiceId';
import { CallMode, CallState } from '../../types/Calling';
import type { StateType } from '../reducer';
import { missingCaseError } from '../../util/missingCaseError';
@ -127,14 +127,14 @@ const mapStateToActiveCallProp = (
return undefined;
}
const conversationSelectorByUuid = memoize<
(uuid: UUIDStringType) => undefined | ConversationType
>(uuid => {
const convoForUuid = window.ConversationController.lookupOrCreate({
uuid,
const conversationSelectorByAci = memoize<
(aci: AciString) => undefined | ConversationType
>(aci => {
const convoForAci = window.ConversationController.lookupOrCreate({
uuid: aci,
reason: 'CallManager.mapStateToActiveCallProp',
});
return convoForUuid ? conversationSelector(convoForUuid.id) : undefined;
return convoForAci ? conversationSelector(convoForAci.id) : undefined;
});
const baseResult = {
@ -194,7 +194,7 @@ const mapStateToActiveCallProp = (
peekInfo = {
deviceCount: 0,
maxDevices: Infinity,
uuids: [],
acis: [],
},
} = call;
@ -213,8 +213,8 @@ const mapStateToActiveCallProp = (
for (let i = 0; i < call.remoteParticipants.length; i += 1) {
const remoteParticipant = call.remoteParticipants[i];
const remoteConversation = conversationSelectorByUuid(
remoteParticipant.uuid
const remoteConversation = conversationSelectorByAci(
remoteParticipant.aci
);
if (!remoteConversation) {
log.error('Remote participant has no corresponding conversation');
@ -235,12 +235,12 @@ const mapStateToActiveCallProp = (
for (
let i = 0;
i < activeCallState.safetyNumberChangedUuids.length;
i < activeCallState.safetyNumberChangedAcis.length;
i += 1
) {
const uuid = activeCallState.safetyNumberChangedUuids[i];
const aci = activeCallState.safetyNumberChangedAcis[i];
const remoteConversation = conversationSelectorByUuid(uuid);
const remoteConversation = conversationSelectorByAci(aci);
if (!remoteConversation) {
log.error('Remote participant has no corresponding conversation');
continue;
@ -249,12 +249,11 @@ const mapStateToActiveCallProp = (
conversationsWithSafetyNumberChanges.push(remoteConversation);
}
for (let i = 0; i < peekInfo.uuids.length; i += 1) {
const peekedParticipantUuid = peekInfo.uuids[i];
for (let i = 0; i < peekInfo.acis.length; i += 1) {
const peekedParticipantAci = peekInfo.acis[i];
const peekedConversation = conversationSelectorByUuid(
peekedParticipantUuid
);
const peekedConversation =
conversationSelectorByAci(peekedParticipantAci);
if (!peekedConversation) {
log.error('Remote participant has no corresponding conversation');
continue;
@ -303,13 +302,13 @@ const mapStateToIncomingCallProp = (state: StateType) => {
isVideoCall: call.isVideoCall,
};
case CallMode.Group: {
if (!call.ringerUuid) {
if (!call.ringerAci) {
log.error('The incoming group call has no ring state');
return undefined;
}
const conversationSelector = getConversationSelector(state);
const ringer = conversationSelector(call.ringerUuid);
const ringer = conversationSelector(call.ringerAci);
const otherMembersRung = (conversation.sortedGroupMembers ?? []).filter(
c => c.id !== ringer.id && !c.isMe
);

View file

@ -6,7 +6,7 @@ import { connect } from 'react-redux';
import type { StateType } from '../reducer';
import { mapDispatchToProps } from '../actions';
import { strictAssert } from '../../util/assert';
import { lookupConversationWithoutUuid } from '../../util/lookupConversationWithoutUuid';
import { lookupConversationWithoutServiceId } from '../../util/lookupConversationWithoutServiceId';
import type { StatePropsType } from '../../components/conversation/conversation-details/AddGroupMembersModal/ChooseGroupMembersModal';
import { ChooseGroupMembersModal } from '../../components/conversation/conversation-details/AddGroupMembersModal/ChooseGroupMembersModal';
@ -55,7 +55,7 @@ const mapStateToProps = (
i18n: getIntl(state),
theme: getTheme(state),
selectedContacts,
lookupConversationWithoutUuid,
lookupConversationWithoutServiceId,
isUsernamesEnabled: getUsernamesEnabled(state),
};
};

View file

@ -45,8 +45,8 @@ const getOutgoingCallButtonStyle = (
state: StateType
): OutgoingCallButtonStyle => {
const { calling } = state;
const ourACI = getUserACI(state);
strictAssert(ourACI, 'getOutgoingCallButtonStyle missing our uuid');
const ourAci = getUserACI(state);
strictAssert(ourAci, 'getOutgoingCallButtonStyle missing our uuid');
if (getActiveCall(calling)) {
return OutgoingCallButtonStyle.None;
@ -62,7 +62,7 @@ const getOutgoingCallButtonStyle = (
const call = getOwn(calling.callsByConversation, conversation.id);
if (
call?.callMode === CallMode.Group &&
isAnybodyElseInGroupCall(call.peekInfo, ourACI)
isAnybodyElseInGroupCall(call.peekInfo, ourAci)
) {
return OutgoingCallButtonStyle.Join;
}

View file

@ -333,7 +333,7 @@ function PanelElement({
return (
<SmartPendingInvites
conversationId={conversationId}
ourUuid={window.storage.user.getCheckedUuid().toString()}
ourAci={window.storage.user.getCheckedAci()}
/>
);
}

View file

@ -11,7 +11,7 @@ import { DialogExpiredBuild } from '../../components/DialogExpiredBuild';
import type { PropsType as DialogExpiredBuildPropsType } from '../../components/DialogExpiredBuild';
import type { StateType } from '../reducer';
import { missingCaseError } from '../../util/missingCaseError';
import { lookupConversationWithoutUuid } from '../../util/lookupConversationWithoutUuid';
import { lookupConversationWithoutServiceId } from '../../util/lookupConversationWithoutServiceId';
import { isDone as isRegistrationDone } from '../../util/registration';
import { ComposerStep, OneTimeModalState } from '../ducks/conversationsEnums';
@ -246,7 +246,7 @@ const mapStateToProps = (state: StateType) => {
renderCrashReportDialog,
renderExpiredBuildDialog,
renderUnsupportedOSDialog,
lookupConversationWithoutUuid,
lookupConversationWithoutServiceId,
theme: getTheme(state),
};
};

View file

@ -15,11 +15,11 @@ import {
} from '../selectors/conversations';
import { getGroupMemberships } from '../../util/getGroupMemberships';
import { assertDev } from '../../util/assert';
import type { UUIDStringType } from '../../types/UUID';
import type { AciString } from '../../types/ServiceId';
export type SmartPendingInvitesProps = {
conversationId: string;
ourUuid: UUIDStringType;
ourAci: AciString;
};
const mapStateToProps = (