signal-desktop/ts/state/smart/ProfileEditorModal.ts

52 lines
1.4 KiB
TypeScript
Raw Normal View History

2021-07-19 19:26:06 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import { connect } from 'react-redux';
import { mapDispatchToProps } from '../actions';
import {
ProfileEditorModal,
PropsDataType as ProfileEditorModalPropsType,
} from '../../components/ProfileEditorModal';
import { PropsDataType } from '../../components/ProfileEditor';
import { StateType } from '../reducer';
import { getIntl } from '../selectors/user';
import { getEmojiSkinTone } from '../selectors/items';
2021-07-19 19:26:06 +00:00
import { getMe } from '../selectors/conversations';
import { selectRecentEmojis } from '../selectors/emojis';
function mapStateToProps(
state: StateType
): PropsDataType & ProfileEditorModalPropsType {
2021-08-06 00:17:05 +00:00
const {
avatarPath,
avatars: userAvatarData = [],
aboutText,
aboutEmoji,
color,
firstName,
familyName,
id: conversationId,
} = getMe(state);
2021-07-19 19:26:06 +00:00
const recentEmojis = selectRecentEmojis(state);
const skinTone = getEmojiSkinTone(state);
2021-07-19 19:26:06 +00:00
return {
aboutEmoji,
aboutText,
avatarPath,
2021-08-06 00:17:05 +00:00
color,
conversationId,
2021-07-19 19:26:06 +00:00
familyName,
firstName: String(firstName),
hasError: state.globalModals.profileEditorHasError,
i18n: getIntl(state),
recentEmojis,
skinTone,
2021-08-06 00:17:05 +00:00
userAvatarData,
2021-07-19 19:26:06 +00:00
};
}
const smart = connect(mapStateToProps, mapDispatchToProps);
export const SmartProfileEditorModal = smart(ProfileEditorModal);