New feature flag with ability to migrate GV1 groups

This commit is contained in:
Scott Nonnenberg 2020-12-01 08:42:35 -08:00 committed by GitHub
parent 089a6fb5a2
commit 2b8ae412e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 608 additions and 189 deletions

View file

@ -54,6 +54,7 @@ export type ConversationType = {
isAccepted?: boolean;
isArchived?: boolean;
isBlocked?: boolean;
isGroupV1AndDisabled?: boolean;
isPinned?: boolean;
isVerified?: boolean;
activeAt?: number;

View file

@ -0,0 +1,28 @@
// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
import { Provider } from 'react-redux';
import { Store } from 'redux';
import { ModalHost } from '../../components/ModalHost';
import {
SmartGroupV1MigrationDialog,
PropsType,
} from '../smart/GroupV1MigrationDialog';
export const createGroupV1MigrationModal = (
store: Store,
props: PropsType
): React.ReactElement => {
const { onClose } = props;
return (
<Provider store={store}>
<ModalHost onClose={onClose}>
<SmartGroupV1MigrationDialog {...props} />
</ModalHost>
</Provider>
);
};

View file

@ -0,0 +1,59 @@
// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { connect } from 'react-redux';
import { mapDispatchToProps } from '../actions';
import {
GroupV1MigrationDialog,
PropsType as GroupV1MigrationDialogPropsType,
} from '../../components/GroupV1MigrationDialog';
import { ConversationType } from '../ducks/conversations';
import { StateType } from '../reducer';
import { getConversationSelector } from '../selectors/conversations';
import { getIntl } from '../selectors/user';
export type PropsType = {
readonly droppedMemberIds: Array<string>;
readonly invitedMemberIds: Array<string>;
} & Omit<
GroupV1MigrationDialogPropsType,
'i18n' | 'droppedMembers' | 'invitedMembers'
>;
const mapStateToProps = (
state: StateType,
props: PropsType
): GroupV1MigrationDialogPropsType => {
const getConversation = getConversationSelector(state);
const { droppedMemberIds, invitedMemberIds } = props;
const droppedMembers = droppedMemberIds
.map(getConversation)
.filter(Boolean) as Array<ConversationType>;
if (droppedMembers.length !== droppedMemberIds.length) {
window.log.warn(
'smart/GroupV1MigrationDialog: droppedMembers length changed'
);
}
const invitedMembers = invitedMemberIds
.map(getConversation)
.filter(Boolean) as Array<ConversationType>;
if (invitedMembers.length !== invitedMemberIds.length) {
window.log.warn(
'smart/GroupV1MigrationDialog: invitedMembers length changed'
);
}
return {
...props,
droppedMembers,
invitedMembers,
i18n: getIntl(state),
};
};
const smart = connect(mapStateToProps, mapDispatchToProps);
export const SmartGroupV1MigrationDialog = smart(GroupV1MigrationDialog);

View file

@ -101,7 +101,11 @@ const mapStateToProps = (state: StateType, props: ExternalProps) => {
return {
id,
...pick(conversation, ['unreadCount', 'typingContact']),
...pick(conversation, [
'unreadCount',
'typingContact',
'isGroupV1AndDisabled',
]),
...conversationMessages,
selectedMessageId: selectedMessage ? selectedMessage.id : undefined,
i18n: getIntl(state),