2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
2020-12-01 16:42:35 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { mapDispatchToProps } from '../actions';
|
2022-12-08 06:41:37 +00:00
|
|
|
import type { DataPropsType as GroupV1MigrationDialogPropsType } from '../../components/GroupV1MigrationDialog';
|
2021-10-26 19:15:33 +00:00
|
|
|
import { GroupV1MigrationDialog } from '../../components/GroupV1MigrationDialog';
|
|
|
|
import type { ConversationType } from '../ducks/conversations';
|
|
|
|
import type { StateType } from '../reducer';
|
2021-11-20 15:41:21 +00:00
|
|
|
import { getPreferredBadgeSelector } from '../selectors/badges';
|
2020-12-01 16:42:35 +00:00
|
|
|
import { getConversationSelector } from '../selectors/conversations';
|
|
|
|
|
2021-11-20 15:41:21 +00:00
|
|
|
import { getIntl, getTheme } from '../selectors/user';
|
2021-09-17 18:27:53 +00:00
|
|
|
import * as log from '../../logging/log';
|
2020-12-01 16:42:35 +00:00
|
|
|
|
|
|
|
export type PropsType = {
|
|
|
|
readonly droppedMemberIds: Array<string>;
|
|
|
|
readonly invitedMemberIds: Array<string>;
|
|
|
|
} & Omit<
|
|
|
|
GroupV1MigrationDialogPropsType,
|
2021-11-20 15:41:21 +00:00
|
|
|
'i18n' | 'droppedMembers' | 'invitedMembers' | 'theme' | 'getPreferredBadge'
|
2020-12-01 16:42:35 +00:00
|
|
|
>;
|
|
|
|
|
|
|
|
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) {
|
2021-09-17 18:27:53 +00:00
|
|
|
log.warn('smart/GroupV1MigrationDialog: droppedMembers length changed');
|
2020-12-01 16:42:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const invitedMembers = invitedMemberIds
|
|
|
|
.map(getConversation)
|
|
|
|
.filter(Boolean) as Array<ConversationType>;
|
|
|
|
if (invitedMembers.length !== invitedMemberIds.length) {
|
2021-09-17 18:27:53 +00:00
|
|
|
log.warn('smart/GroupV1MigrationDialog: invitedMembers length changed');
|
2020-12-01 16:42:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
...props,
|
|
|
|
droppedMembers,
|
2021-11-20 15:41:21 +00:00
|
|
|
getPreferredBadge: getPreferredBadgeSelector(state),
|
2020-12-01 16:42:35 +00:00
|
|
|
invitedMembers,
|
|
|
|
i18n: getIntl(state),
|
2021-11-20 15:41:21 +00:00
|
|
|
theme: getTheme(state),
|
2020-12-01 16:42:35 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const smart = connect(mapStateToProps, mapDispatchToProps);
|
|
|
|
|
|
|
|
export const SmartGroupV1MigrationDialog = smart(GroupV1MigrationDialog);
|