Use UUIDs in group database schema

This commit is contained in:
Fedor Indutny 2021-10-26 15:59:08 -07:00 committed by GitHub
parent 74fde10ff5
commit 63fcdbe787
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 4530 additions and 3664 deletions

View file

@ -40,12 +40,13 @@ import type {
StartCallType,
} from '../state/ducks/calling';
import type { LocalizerType } 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: string;
uuid: UUIDStringType;
};
export type PropsType = {

View file

@ -3,7 +3,6 @@
import * as React from 'react';
import { times } from 'lodash';
import { v4 as generateUuid } from 'uuid';
import { storiesOf } from '@storybook/react';
import { boolean, select, number } from '@storybook/addon-knobs';
import { action } from '@storybook/addon-actions';
@ -21,7 +20,10 @@ import type { PropsType } from './CallScreen';
import { CallScreen } from './CallScreen';
import { setupI18n } from '../util/setupI18n';
import { missingCaseError } from '../util/missingCaseError';
import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation';
import {
getDefaultConversation,
getDefaultConversationWithUuid,
} from '../test-both/helpers/getDefaultConversation';
import { fakeGetGroupCallVideoFrameSource } from '../test-both/helpers/fakeGetGroupCallVideoFrameSource';
import enMessages from '../../_locales/en/messages.json';
@ -286,10 +288,9 @@ const allRemoteParticipants = times(MAX_PARTICIPANTS).map(index => ({
presenting: false,
sharingScreen: false,
videoAspectRatio: 1.3,
...getDefaultConversation({
...getDefaultConversationWithUuid({
isBlocked: index === 10 || index === MAX_PARTICIPANTS - 1,
title: `Participant ${index + 1}`,
uuid: generateUuid(),
}),
}));

View file

@ -38,6 +38,7 @@ 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';
@ -57,7 +58,7 @@ export type PropsType = {
phoneNumber?: string;
profileName?: string;
title: string;
uuid: string;
uuid: UUIDStringType;
};
openSystemPreferencesAction: () => unknown;
setGroupCallVideoRequest: (_: Array<GroupCallVideoRequest>) => void;

View file

@ -6,15 +6,18 @@ import { times } from 'lodash';
import { storiesOf } from '@storybook/react';
import { boolean } from '@storybook/addon-knobs';
import { action } from '@storybook/addon-actions';
import { v4 as generateUuid } from 'uuid';
import { AvatarColors } from '../types/Colors';
import type { ConversationType } from '../state/ducks/conversations';
import type { PropsType } from './CallingLobby';
import { CallingLobby } from './CallingLobby';
import { setupI18n } from '../util/setupI18n';
import { UUID } from '../types/UUID';
import enMessages from '../../_locales/en/messages.json';
import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation';
import {
getDefaultConversation,
getDefaultConversationWithUuid,
} from '../test-both/helpers/getDefaultConversation';
const i18n = setupI18n('en', enMessages);
@ -60,8 +63,8 @@ const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => {
isCallFull: boolean('isCallFull', overrideProps.isCallFull || false),
me: overrideProps.me || {
color: AvatarColors[0],
id: generateUuid(),
uuid: generateUuid(),
id: UUID.generate().toString(),
uuid: UUID.generate().toString(),
},
onCallCanceled: action('on-call-canceled'),
onJoinCall: action('on-join-call'),
@ -81,8 +84,7 @@ const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => {
};
const fakePeekedParticipant = (conversationProps: Partial<ConversationType>) =>
getDefaultConversation({
uuid: generateUuid(),
getDefaultConversationWithUuid({
...conversationProps,
});
@ -106,8 +108,8 @@ story.add('No Camera, local avatar', () => {
me: {
avatarPath: '/fixtures/kitten-4-112-112.jpg',
color: AvatarColors[0],
id: generateUuid(),
uuid: generateUuid(),
id: UUID.generate().toString(),
uuid: UUID.generate().toString(),
},
});
return <CallingLobby {...props} />;
@ -141,11 +143,11 @@ story.add('Group Call - 1 peeked participant', () => {
});
story.add('Group Call - 1 peeked participant (self)', () => {
const uuid = generateUuid();
const uuid = UUID.generate().toString();
const props = createProps({
isGroupCall: true,
me: {
id: generateUuid(),
id: UUID.generate().toString(),
uuid,
},
peekedParticipants: [fakePeekedParticipant({ title: 'Ash', uuid })],

View file

@ -19,6 +19,7 @@ import {
} 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';
@ -52,7 +53,7 @@ export type PropsType = {
avatarPath?: string;
id: string;
color?: AvatarColorType;
uuid: string;
uuid: UUIDStringType;
};
onCallCanceled: () => void;
onJoinCall: () => void;

View file

@ -5,13 +5,12 @@ import * as React from 'react';
import { sample } from 'lodash';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { v4 as generateUuid } from 'uuid';
import type { PropsType } from './CallingParticipantsList';
import { CallingParticipantsList } from './CallingParticipantsList';
import { AvatarColors } from '../types/Colors';
import type { GroupCallRemoteParticipantType } from '../types/Calling';
import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation';
import { getDefaultConversationWithUuid } from '../test-both/helpers/getDefaultConversation';
import { setupI18n } from '../util/setupI18n';
import enMessages from '../../_locales/en/messages.json';
@ -27,14 +26,13 @@ function createParticipant(
presenting: Boolean(participantProps.presenting),
sharingScreen: Boolean(participantProps.sharingScreen),
videoAspectRatio: 1.3,
...getDefaultConversation({
...getDefaultConversationWithUuid({
avatarPath: participantProps.avatarPath,
color: sample(AvatarColors),
isBlocked: Boolean(participantProps.isBlocked),
name: participantProps.name,
profileName: participantProps.title,
title: String(participantProps.title),
uuid: generateUuid(),
}),
};
}

View file

@ -16,6 +16,7 @@ import type { EmojiPickDataType } from './emoji/EmojiPicker';
import { convertShortName } from './emoji/lib';
import type { LocalizerType, BodyRangeType } from '../types/Util';
import type { ConversationType } from '../state/ducks/conversations';
import { isValidUuid } from '../types/UUID';
import { MentionBlot } from '../quill/mentions/blot';
import {
matchEmojiImage,
@ -465,7 +466,7 @@ export function CompositionInput(props: Props): React.ReactElement {
const currentMemberUuids = currentMembers
.map(m => m.uuid)
.filter((uuid): uuid is string => uuid !== undefined);
.filter(isValidUuid);
const newDelta = getDeltaToRemoveStaleMentions(ops, currentMemberUuids);

View file

@ -4,13 +4,12 @@
import type { FC } from 'react';
import React from 'react';
import { memoize, times } from 'lodash';
import { v4 as generateUuid } from 'uuid';
import { storiesOf } from '@storybook/react';
import { number } from '@storybook/addon-knobs';
import { GroupCallOverflowArea } from './GroupCallOverflowArea';
import { setupI18n } from '../util/setupI18n';
import { getDefaultConversation } from '../test-both/helpers/getDefaultConversation';
import { getDefaultConversationWithUuid } from '../test-both/helpers/getDefaultConversation';
import { fakeGetGroupCallVideoFrameSource } from '../test-both/helpers/fakeGetGroupCallVideoFrameSource';
import { FRAME_BUFFER_SIZE } from '../calling/constants';
import enMessages from '../../_locales/en/messages.json';
@ -26,10 +25,9 @@ const allRemoteParticipants = times(MAX_PARTICIPANTS).map(index => ({
presenting: false,
sharingScreen: false,
videoAspectRatio: 1.3,
...getDefaultConversation({
...getDefaultConversationWithUuid({
isBlocked: index === 10 || index === MAX_PARTICIPANTS - 1,
title: `Participant ${index + 1}`,
uuid: generateUuid(),
}),
}));

View file

@ -6,6 +6,7 @@ import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { setupI18n } from '../../util/setupI18n';
import { UUID } from '../../types/UUID';
import enMessages from '../../../_locales/en/messages.json';
import type { GroupV2ChangeType } from '../../groups';
import { SignalService as Proto } from '../../protobuf';
@ -14,12 +15,12 @@ import { GroupV2Change } from './GroupV2Change';
const i18n = setupI18n('en', enMessages);
const OUR_ID = 'OUR_ID';
const CONTACT_A = 'CONTACT_A';
const CONTACT_B = 'CONTACT_B';
const CONTACT_C = 'CONTACT_C';
const ADMIN_A = 'ADMIN_A';
const INVITEE_A = 'INVITEE_A';
const OUR_ID = UUID.generate().toString();
const CONTACT_A = UUID.generate().toString();
const CONTACT_B = UUID.generate().toString();
const CONTACT_C = UUID.generate().toString();
const ADMIN_A = UUID.generate().toString();
const INVITEE_A = UUID.generate().toString();
const AccessControlEnum = Proto.AccessControl.AccessRequired;
const RoleEnum = Proto.Member.Role;
@ -35,7 +36,7 @@ const renderChange = (change: GroupV2ChangeType, groupName?: string) => (
change={change}
groupName={groupName}
i18n={i18n}
ourConversationId={OUR_ID}
ourUuid={OUR_ID}
renderContact={renderContact}
/>
);
@ -62,7 +63,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
},
{
type: 'member-add',
conversationId: OUR_ID,
uuid: OUR_ID,
},
{
type: 'description',
@ -70,7 +71,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
},
{
type: 'member-privilege',
conversationId: OUR_ID,
uuid: OUR_ID,
newPrivilege: RoleEnum.ADMINISTRATOR,
},
],
@ -402,7 +403,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add',
conversationId: OUR_ID,
uuid: OUR_ID,
},
],
})}
@ -411,7 +412,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add',
conversationId: OUR_ID,
uuid: OUR_ID,
},
],
})}
@ -419,7 +420,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add',
conversationId: OUR_ID,
uuid: OUR_ID,
},
],
})}
@ -428,7 +429,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add',
conversationId: CONTACT_A,
uuid: CONTACT_A,
},
],
})}
@ -437,7 +438,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add',
conversationId: CONTACT_A,
uuid: CONTACT_A,
},
],
})}
@ -445,7 +446,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add',
conversationId: CONTACT_A,
uuid: CONTACT_A,
},
],
})}
@ -461,7 +462,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add-from-invite',
conversationId: OUR_ID,
uuid: OUR_ID,
inviter: CONTACT_B,
},
],
@ -470,7 +471,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add-from-invite',
conversationId: OUR_ID,
uuid: OUR_ID,
inviter: CONTACT_A,
},
],
@ -481,7 +482,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add-from-invite',
conversationId: CONTACT_A,
uuid: CONTACT_A,
inviter: CONTACT_B,
},
],
@ -491,7 +492,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add-from-invite',
conversationId: CONTACT_B,
uuid: CONTACT_B,
inviter: CONTACT_C,
},
],
@ -500,7 +501,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add-from-invite',
conversationId: CONTACT_A,
uuid: CONTACT_A,
inviter: CONTACT_B,
},
],
@ -511,7 +512,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add-from-invite',
conversationId: OUR_ID,
uuid: OUR_ID,
inviter: CONTACT_A,
},
],
@ -521,7 +522,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add-from-invite',
conversationId: OUR_ID,
uuid: OUR_ID,
},
],
})}
@ -530,7 +531,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add-from-invite',
conversationId: CONTACT_A,
uuid: CONTACT_A,
inviter: OUR_ID,
},
],
@ -540,7 +541,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add-from-invite',
conversationId: CONTACT_A,
uuid: CONTACT_A,
inviter: CONTACT_B,
},
],
@ -550,7 +551,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add-from-invite',
conversationId: CONTACT_A,
uuid: CONTACT_A,
},
],
})}
@ -565,7 +566,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add-from-link',
conversationId: OUR_ID,
uuid: OUR_ID,
},
],
})}
@ -574,7 +575,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add-from-link',
conversationId: CONTACT_A,
uuid: CONTACT_A,
},
],
})}
@ -582,7 +583,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add-from-link',
conversationId: CONTACT_A,
uuid: CONTACT_A,
},
],
})}
@ -597,7 +598,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add-from-admin-approval',
conversationId: OUR_ID,
uuid: OUR_ID,
},
],
})}
@ -605,7 +606,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add-from-admin-approval',
conversationId: OUR_ID,
uuid: OUR_ID,
},
],
})}
@ -614,7 +615,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add-from-admin-approval',
conversationId: CONTACT_A,
uuid: CONTACT_A,
},
],
})}
@ -623,7 +624,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add-from-admin-approval',
conversationId: CONTACT_A,
uuid: CONTACT_A,
},
],
})}
@ -631,7 +632,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-add-from-admin-approval',
conversationId: CONTACT_A,
uuid: CONTACT_A,
},
],
})}
@ -646,7 +647,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-remove',
conversationId: OUR_ID,
uuid: OUR_ID,
},
],
})}
@ -655,7 +656,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-remove',
conversationId: OUR_ID,
uuid: OUR_ID,
},
],
})}
@ -663,7 +664,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-remove',
conversationId: OUR_ID,
uuid: OUR_ID,
},
],
})}
@ -672,7 +673,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-remove',
conversationId: CONTACT_A,
uuid: CONTACT_A,
},
],
})}
@ -681,7 +682,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-remove',
conversationId: CONTACT_A,
uuid: CONTACT_A,
},
],
})}
@ -690,7 +691,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-remove',
conversationId: CONTACT_A,
uuid: CONTACT_A,
},
],
})}
@ -698,7 +699,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-remove',
conversationId: CONTACT_A,
uuid: CONTACT_A,
},
],
})}
@ -713,7 +714,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-privilege',
conversationId: OUR_ID,
uuid: OUR_ID,
newPrivilege: RoleEnum.ADMINISTRATOR,
},
],
@ -722,7 +723,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-privilege',
conversationId: OUR_ID,
uuid: OUR_ID,
newPrivilege: RoleEnum.ADMINISTRATOR,
},
],
@ -732,7 +733,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-privilege',
conversationId: CONTACT_A,
uuid: CONTACT_A,
newPrivilege: RoleEnum.ADMINISTRATOR,
},
],
@ -742,7 +743,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-privilege',
conversationId: CONTACT_A,
uuid: CONTACT_A,
newPrivilege: RoleEnum.ADMINISTRATOR,
},
],
@ -751,7 +752,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-privilege',
conversationId: CONTACT_A,
uuid: CONTACT_A,
newPrivilege: RoleEnum.ADMINISTRATOR,
},
],
@ -761,7 +762,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-privilege',
conversationId: OUR_ID,
uuid: OUR_ID,
newPrivilege: RoleEnum.DEFAULT,
},
],
@ -770,7 +771,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-privilege',
conversationId: OUR_ID,
uuid: OUR_ID,
newPrivilege: RoleEnum.DEFAULT,
},
],
@ -780,7 +781,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-privilege',
conversationId: CONTACT_A,
uuid: CONTACT_A,
newPrivilege: RoleEnum.DEFAULT,
},
],
@ -790,7 +791,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-privilege',
conversationId: CONTACT_A,
uuid: CONTACT_A,
newPrivilege: RoleEnum.DEFAULT,
},
],
@ -799,7 +800,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'member-privilege',
conversationId: CONTACT_A,
uuid: CONTACT_A,
newPrivilege: RoleEnum.DEFAULT,
},
],
@ -815,7 +816,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'pending-add-one',
conversationId: OUR_ID,
uuid: OUR_ID,
},
],
})}
@ -823,7 +824,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'pending-add-one',
conversationId: OUR_ID,
uuid: OUR_ID,
},
],
})}
@ -832,7 +833,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'pending-add-one',
conversationId: INVITEE_A,
uuid: INVITEE_A,
},
],
})}
@ -841,7 +842,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'pending-add-one',
conversationId: INVITEE_A,
uuid: INVITEE_A,
},
],
})}
@ -849,7 +850,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'pending-add-one',
conversationId: INVITEE_A,
uuid: INVITEE_A,
},
],
})}
@ -896,7 +897,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'pending-remove-one',
conversationId: INVITEE_A,
uuid: INVITEE_A,
inviter: OUR_ID,
},
],
@ -906,7 +907,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'pending-remove-one',
conversationId: INVITEE_A,
uuid: INVITEE_A,
inviter: OUR_ID,
},
],
@ -916,7 +917,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'pending-remove-one',
conversationId: INVITEE_A,
uuid: INVITEE_A,
inviter: OUR_ID,
},
],
@ -925,7 +926,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'pending-remove-one',
conversationId: INVITEE_A,
uuid: INVITEE_A,
inviter: OUR_ID,
},
],
@ -935,7 +936,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'pending-remove-one',
conversationId: INVITEE_A,
uuid: INVITEE_A,
},
],
})}
@ -944,7 +945,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'pending-remove-one',
conversationId: INVITEE_A,
uuid: INVITEE_A,
inviter: CONTACT_B,
},
],
@ -955,7 +956,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'pending-remove-one',
conversationId: OUR_ID,
uuid: OUR_ID,
inviter: CONTACT_B,
},
],
@ -965,7 +966,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'pending-remove-one',
conversationId: CONTACT_B,
uuid: CONTACT_B,
inviter: CONTACT_A,
},
],
@ -976,7 +977,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'pending-remove-one',
conversationId: INVITEE_A,
uuid: INVITEE_A,
inviter: CONTACT_B,
},
],
@ -986,7 +987,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'pending-remove-one',
conversationId: INVITEE_A,
uuid: INVITEE_A,
inviter: CONTACT_B,
},
],
@ -995,7 +996,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'pending-remove-one',
conversationId: INVITEE_A,
uuid: INVITEE_A,
inviter: CONTACT_B,
},
],
@ -1006,7 +1007,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'pending-remove-one',
conversationId: INVITEE_A,
uuid: INVITEE_A,
},
],
})}
@ -1015,7 +1016,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'pending-remove-one',
conversationId: INVITEE_A,
uuid: INVITEE_A,
},
],
})}
@ -1023,7 +1024,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'pending-remove-one',
conversationId: INVITEE_A,
uuid: INVITEE_A,
},
],
})}
@ -1128,7 +1129,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'admin-approval-add-one',
conversationId: OUR_ID,
uuid: OUR_ID,
},
],
})}
@ -1136,7 +1137,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'admin-approval-add-one',
conversationId: CONTACT_A,
uuid: CONTACT_A,
},
],
})}
@ -1151,7 +1152,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'admin-approval-remove-one',
conversationId: OUR_ID,
uuid: OUR_ID,
},
],
})}
@ -1159,7 +1160,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'admin-approval-remove-one',
conversationId: OUR_ID,
uuid: OUR_ID,
},
],
})}
@ -1168,7 +1169,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'admin-approval-remove-one',
conversationId: CONTACT_A,
uuid: CONTACT_A,
},
],
})}
@ -1177,7 +1178,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'admin-approval-remove-one',
conversationId: CONTACT_A,
uuid: CONTACT_A,
},
],
})}
@ -1186,7 +1187,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'admin-approval-remove-one',
conversationId: CONTACT_A,
uuid: CONTACT_A,
},
],
})}
@ -1194,7 +1195,7 @@ storiesOf('Components/Conversation/GroupV2Change', module)
details: [
{
type: 'admin-approval-remove-one',
conversationId: CONTACT_A,
uuid: CONTACT_A,
},
],
})}

View file

@ -9,6 +9,7 @@ import type { ReplacementValuesType } from '../../types/I18N';
import type { FullJSXType } from '../Intl';
import { Intl } from '../Intl';
import type { LocalizerType } from '../../types/Util';
import type { UUIDStringType } from '../../types/UUID';
import { GroupDescriptionText } from '../GroupDescriptionText';
import { Button, ButtonSize, ButtonVariant } from '../Button';
import { SystemMessage } from './SystemMessage';
@ -21,7 +22,7 @@ import { Modal } from '../Modal';
export type PropsDataType = {
groupName?: string;
ourConversationId: string;
ourUuid: UUIDStringType;
change: GroupV2ChangeType;
};
@ -78,11 +79,11 @@ const changeToIconMap = new Map<string, GroupIconType>([
function getIcon(
detail: GroupV2ChangeDetailType,
fromId?: string
fromId?: UUIDStringType
): GroupIconType {
const changeType = detail.type;
let possibleIcon = changeToIconMap.get(changeType);
const isSameId = fromId === get(detail, 'conversationId', null);
const isSameId = fromId === get(detail, 'uuid', null);
if (isSameId) {
if (changeType === 'member-remove') {
possibleIcon = 'group-leave';
@ -103,7 +104,7 @@ function GroupV2Detail({
}: {
detail: GroupV2ChangeDetailType;
i18n: LocalizerType;
fromId?: string;
fromId?: UUIDStringType;
onButtonClick: (x: string) => unknown;
text: FullJSXType;
}): JSX.Element {
@ -132,7 +133,7 @@ function GroupV2Detail({
}
export function GroupV2Change(props: PropsType): ReactElement {
const { change, groupName, i18n, ourConversationId, renderContact } = props;
const { change, groupName, i18n, ourUuid, renderContact } = props;
const [groupDescription, setGroupDescription] = useState<
string | undefined
@ -142,7 +143,7 @@ export function GroupV2Change(props: PropsType): ReactElement {
<>
{renderChange(change, {
i18n,
ourConversationId,
ourUuid,
renderContact,
renderString: renderStringToIntl,
}).map((text: FullJSXType, index: number) => (

View file

@ -301,8 +301,8 @@ const actions = () => ({
),
checkForAccount: action('checkForAccount'),
clearChangedMessages: action('clearChangedMessages'),
clearInvitedConversationsForNewlyCreatedGroup: action(
'clearInvitedConversationsForNewlyCreatedGroup'
clearInvitedUuidsForNewlyCreatedGroup: action(
'clearInvitedUuidsForNewlyCreatedGroup'
),
setLoadCountdownStart: action('setLoadCountdownStart'),
setIsNearBottom: action('setIsNearBottom'),

View file

@ -130,7 +130,7 @@ export type PropsActionsType = {
groupNameCollisions: Readonly<GroupNameCollisionsWithIdsByTitle>
) => void;
clearChangedMessages: (conversationId: string) => unknown;
clearInvitedConversationsForNewlyCreatedGroup: () => void;
clearInvitedUuidsForNewlyCreatedGroup: () => void;
closeContactSpoofingReview: () => void;
setLoadCountdownStart: (
conversationId: string,
@ -231,7 +231,7 @@ const getActions = createSelector(
const unsafe = pick(props, [
'acknowledgeGroupMemberNameCollisions',
'clearChangedMessages',
'clearInvitedConversationsForNewlyCreatedGroup',
'clearInvitedUuidsForNewlyCreatedGroup',
'closeContactSpoofingReview',
'setLoadCountdownStart',
'setIsNearBottom',
@ -1313,7 +1313,7 @@ export class Timeline extends React.PureComponent<PropsType, StateType> {
const {
acknowledgeGroupMemberNameCollisions,
areWeAdmin,
clearInvitedConversationsForNewlyCreatedGroup,
clearInvitedUuidsForNewlyCreatedGroup,
closeContactSpoofingReview,
contactSpoofingReview,
i18n,
@ -1566,7 +1566,7 @@ export class Timeline extends React.PureComponent<PropsType, StateType> {
<NewlyCreatedGroupInvitedContactsDialog
contacts={invitedContactsForNewlyCreatedGroup}
i18n={i18n}
onClose={clearInvitedConversationsForNewlyCreatedGroup}
onClose={clearInvitedUuidsForNewlyCreatedGroup}
/>
)}

View file

@ -7,6 +7,7 @@ import { times } from 'lodash';
import { storiesOf } from '@storybook/react';
import { action } from '@storybook/addon-actions';
import { UUID } from '../../../types/UUID';
import { setupI18n } from '../../../util/setupI18n';
import enMessages from '../../../../_locales/en/messages.json';
import type { PropsType } from './PendingInvites';
@ -40,11 +41,13 @@ const conversation: ConversationType = {
sharedGroupNames: [],
};
const OUR_UUID = UUID.generate().toString();
const createProps = (): PropsType => ({
approvePendingMembership: action('approvePendingMembership'),
conversation,
i18n,
ourConversationId: 'abc123',
ourUuid: OUR_UUID,
pendingApprovalMemberships: times(5, () => ({
member: getDefaultConversation(),
})),
@ -52,13 +55,13 @@ const createProps = (): PropsType => ({
...times(4, () => ({
member: getDefaultConversation(),
metadata: {
addedByUserId: 'abc123',
addedByUserId: OUR_UUID,
},
})),
...times(8, () => ({
member: getDefaultConversation(),
metadata: {
addedByUserId: 'def456',
addedByUserId: UUID.generate().toString(),
},
})),
],

View file

@ -7,6 +7,7 @@ import _ from 'lodash';
import type { ConversationType } from '../../../state/ducks/conversations';
import type { LocalizerType } from '../../../types/Util';
import type { UUIDStringType } from '../../../types/UUID';
import { Avatar } from '../../Avatar';
import { ConfirmationDialog } from '../../ConfirmationDialog';
import { PanelSection } from './PanelSection';
@ -16,7 +17,7 @@ import { ConversationDetailsIcon, IconType } from './ConversationDetailsIcon';
export type PropsType = {
readonly conversation?: ConversationType;
readonly i18n: LocalizerType;
readonly ourConversationId?: string;
readonly ourUuid?: UUIDStringType;
readonly pendingApprovalMemberships: ReadonlyArray<GroupV2RequestingMembership>;
readonly pendingMemberships: ReadonlyArray<GroupV2PendingMembership>;
readonly approvePendingMembership: (conversationId: string) => void;
@ -25,7 +26,7 @@ export type PropsType = {
export type GroupV2PendingMembership = {
metadata: {
addedByUserId?: string;
addedByUserId?: UUIDStringType;
};
member: ConversationType;
};
@ -54,14 +55,14 @@ export const PendingInvites: React.ComponentType<PropsType> = ({
approvePendingMembership,
conversation,
i18n,
ourConversationId,
ourUuid,
pendingMemberships,
pendingApprovalMemberships,
revokePendingMemberships,
}) => {
if (!conversation || !ourConversationId) {
if (!conversation || !ourUuid) {
throw new Error(
'PendingInvites rendered without a conversation or ourConversationId'
'PendingInvites rendered without a conversation or ourUuid'
);
}
@ -131,7 +132,7 @@ export const PendingInvites: React.ComponentType<PropsType> = ({
i18n={i18n}
members={conversation.sortedGroupMembers || []}
memberships={pendingMemberships}
ourConversationId={ourConversationId}
ourUuid={ourUuid}
setStagedMemberships={setStagedMemberships}
/>
) : null}
@ -142,7 +143,7 @@ export const PendingInvites: React.ComponentType<PropsType> = ({
i18n={i18n}
members={conversation.sortedGroupMembers || []}
onClose={() => setStagedMemberships(null)}
ourConversationId={ourConversationId}
ourUuid={ourUuid}
revokePendingMemberships={revokePendingMemberships}
stagedMemberships={stagedMemberships}
/>
@ -156,7 +157,7 @@ function MembershipActionConfirmation({
i18n,
members,
onClose,
ourConversationId,
ourUuid,
revokePendingMemberships,
stagedMemberships,
}: {
@ -164,7 +165,7 @@ function MembershipActionConfirmation({
i18n: LocalizerType;
members: Array<ConversationType>;
onClose: () => void;
ourConversationId: string;
ourUuid: string;
revokePendingMemberships: (conversationIds: Array<string>) => void;
stagedMemberships: Array<StagedMembershipType>;
}) {
@ -216,7 +217,7 @@ function MembershipActionConfirmation({
{getConfirmationMessage({
i18n,
members,
ourConversationId,
ourUuid,
stagedMemberships,
})}
</ConfirmationDialog>
@ -226,12 +227,12 @@ function MembershipActionConfirmation({
function getConfirmationMessage({
i18n,
members,
ourConversationId,
ourUuid,
stagedMemberships,
}: Readonly<{
i18n: LocalizerType;
members: ReadonlyArray<ConversationType>;
ourConversationId: string;
ourUuid: string;
stagedMemberships: ReadonlyArray<StagedMembershipType>;
}>): string {
if (!stagedMemberships || !stagedMemberships.length) {
@ -261,8 +262,7 @@ function getConfirmationMessage({
const firstPendingMembership = firstMembership as GroupV2PendingMembership;
// Pending invite
const invitedByUs =
firstPendingMembership.metadata.addedByUserId === ourConversationId;
const invitedByUs = firstPendingMembership.metadata.addedByUserId === ourUuid;
if (invitedByUs) {
return i18n('PendingInvites--revoke-for', {
@ -364,14 +364,14 @@ function MembersPendingProfileKey({
i18n,
members,
memberships,
ourConversationId,
ourUuid,
setStagedMemberships,
}: Readonly<{
conversation: ConversationType;
i18n: LocalizerType;
members: Array<ConversationType>;
memberships: ReadonlyArray<GroupV2PendingMembership>;
ourConversationId: string;
ourUuid: string;
setStagedMemberships: (stagedMembership: Array<StagedMembershipType>) => void;
}>) {
const groupedPendingMemberships = _.groupBy(
@ -380,7 +380,7 @@ function MembersPendingProfileKey({
);
const {
[ourConversationId]: ourPendingMemberships,
[ourUuid]: ourPendingMemberships,
...otherPendingMembershipGroups
} = groupedPendingMemberships;