2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2021-07-19 19:26:06 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
2024-03-13 20:44:13 +00:00
|
|
|
import React, { memo } from 'react';
|
|
|
|
import { useSelector } from 'react-redux';
|
2021-10-26 19:15:33 +00:00
|
|
|
import { ProfileEditorModal } from '../../components/ProfileEditorModal';
|
2024-03-13 20:44:13 +00:00
|
|
|
import { useConversationsActions } from '../ducks/conversations';
|
|
|
|
import { useGlobalModalActions } from '../ducks/globalModals';
|
|
|
|
import { useItemsActions } from '../ducks/items';
|
|
|
|
import { useToastActions } from '../ducks/toast';
|
|
|
|
import { useUsernameActions } from '../ducks/username';
|
|
|
|
import { getMe } from '../selectors/conversations';
|
|
|
|
import { selectRecentEmojis } from '../selectors/emojis';
|
|
|
|
import {
|
|
|
|
getProfileEditorHasError,
|
|
|
|
getProfileEditorInitialEditState,
|
|
|
|
} from '../selectors/globalModals';
|
2023-02-13 18:51:41 +00:00
|
|
|
import {
|
|
|
|
getEmojiSkinTone,
|
2023-07-20 03:14:08 +00:00
|
|
|
getHasCompletedUsernameLinkOnboarding,
|
2023-11-03 22:05:11 +00:00
|
|
|
getUsernameCorrupted,
|
2023-07-20 03:14:08 +00:00
|
|
|
getUsernameLink,
|
2024-03-13 20:44:13 +00:00
|
|
|
getUsernameLinkColor,
|
2023-11-03 22:05:11 +00:00
|
|
|
getUsernameLinkCorrupted,
|
2023-02-13 18:51:41 +00:00
|
|
|
} from '../selectors/items';
|
2024-03-13 20:44:13 +00:00
|
|
|
import { getIntl } from '../selectors/user';
|
2023-07-20 03:14:08 +00:00
|
|
|
import {
|
|
|
|
getUsernameEditState,
|
|
|
|
getUsernameLinkState,
|
|
|
|
} from '../selectors/username';
|
2024-03-13 20:44:13 +00:00
|
|
|
import type { SmartEditUsernameModalBodyProps } from './EditUsernameModalBody';
|
|
|
|
import { SmartEditUsernameModalBody } from './EditUsernameModalBody';
|
2022-10-18 17:12:02 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
function renderEditUsernameModalBody(
|
|
|
|
props: SmartEditUsernameModalBodyProps
|
|
|
|
): JSX.Element {
|
2022-10-18 17:12:02 +00:00
|
|
|
return <SmartEditUsernameModalBody {...props} />;
|
|
|
|
}
|
2021-07-19 19:26:06 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export const SmartProfileEditorModal = memo(function SmartProfileEditorModal() {
|
|
|
|
const i18n = useSelector(getIntl);
|
2021-08-06 00:17:05 +00:00
|
|
|
const {
|
|
|
|
aboutEmoji,
|
2024-03-13 20:44:13 +00:00
|
|
|
aboutText,
|
|
|
|
avatars: userAvatarData = [],
|
2021-08-06 00:17:05 +00:00
|
|
|
color,
|
|
|
|
familyName,
|
2024-03-13 20:44:13 +00:00
|
|
|
firstName,
|
2021-08-06 00:17:05 +00:00
|
|
|
id: conversationId,
|
2024-07-11 19:44:09 +00:00
|
|
|
profileAvatarUrl,
|
2021-11-01 19:13:35 +00:00
|
|
|
username,
|
2024-03-13 20:44:13 +00:00
|
|
|
} = useSelector(getMe);
|
|
|
|
const hasCompletedUsernameLinkOnboarding = useSelector(
|
|
|
|
getHasCompletedUsernameLinkOnboarding
|
|
|
|
);
|
|
|
|
const hasError = useSelector(getProfileEditorHasError);
|
|
|
|
const initialEditState = useSelector(getProfileEditorInitialEditState);
|
|
|
|
const recentEmojis = useSelector(selectRecentEmojis);
|
|
|
|
const skinTone = useSelector(getEmojiSkinTone);
|
|
|
|
const usernameCorrupted = useSelector(getUsernameCorrupted);
|
|
|
|
const usernameEditState = useSelector(getUsernameEditState);
|
|
|
|
const usernameLink = useSelector(getUsernameLink);
|
|
|
|
const usernameLinkColor = useSelector(getUsernameLinkColor);
|
|
|
|
const usernameLinkCorrupted = useSelector(getUsernameLinkCorrupted);
|
|
|
|
const usernameLinkState = useSelector(getUsernameLinkState);
|
2022-10-18 17:12:02 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
const {
|
|
|
|
replaceAvatar,
|
|
|
|
saveAvatarToDisk,
|
|
|
|
saveAttachment,
|
|
|
|
deleteAvatarFromDisk,
|
|
|
|
myProfileChanged,
|
|
|
|
} = useConversationsActions();
|
|
|
|
const {
|
|
|
|
resetUsernameLink,
|
|
|
|
setUsernameLinkColor,
|
|
|
|
setUsernameEditState,
|
|
|
|
openUsernameReservationModal,
|
|
|
|
markCompletedUsernameLinkOnboarding,
|
|
|
|
deleteUsername,
|
|
|
|
} = useUsernameActions();
|
|
|
|
const { toggleProfileEditor, toggleProfileEditorHasError } =
|
|
|
|
useGlobalModalActions();
|
|
|
|
const { showToast } = useToastActions();
|
|
|
|
const { onSetSkinTone } = useItemsActions();
|
2021-07-19 19:26:06 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
return (
|
|
|
|
<ProfileEditorModal
|
|
|
|
aboutEmoji={aboutEmoji}
|
|
|
|
aboutText={aboutText}
|
|
|
|
color={color}
|
|
|
|
conversationId={conversationId}
|
|
|
|
deleteAvatarFromDisk={deleteAvatarFromDisk}
|
|
|
|
deleteUsername={deleteUsername}
|
|
|
|
familyName={familyName}
|
|
|
|
firstName={firstName ?? ''}
|
|
|
|
hasCompletedUsernameLinkOnboarding={hasCompletedUsernameLinkOnboarding}
|
|
|
|
hasError={hasError}
|
|
|
|
i18n={i18n}
|
|
|
|
initialEditState={initialEditState}
|
|
|
|
markCompletedUsernameLinkOnboarding={markCompletedUsernameLinkOnboarding}
|
|
|
|
myProfileChanged={myProfileChanged}
|
|
|
|
onSetSkinTone={onSetSkinTone}
|
|
|
|
openUsernameReservationModal={openUsernameReservationModal}
|
2024-07-11 19:44:09 +00:00
|
|
|
profileAvatarUrl={profileAvatarUrl}
|
2024-03-13 20:44:13 +00:00
|
|
|
recentEmojis={recentEmojis}
|
|
|
|
renderEditUsernameModalBody={renderEditUsernameModalBody}
|
|
|
|
replaceAvatar={replaceAvatar}
|
|
|
|
resetUsernameLink={resetUsernameLink}
|
|
|
|
saveAttachment={saveAttachment}
|
|
|
|
saveAvatarToDisk={saveAvatarToDisk}
|
|
|
|
setUsernameEditState={setUsernameEditState}
|
|
|
|
setUsernameLinkColor={setUsernameLinkColor}
|
|
|
|
showToast={showToast}
|
|
|
|
skinTone={skinTone}
|
|
|
|
toggleProfileEditor={toggleProfileEditor}
|
|
|
|
toggleProfileEditorHasError={toggleProfileEditorHasError}
|
|
|
|
userAvatarData={userAvatarData}
|
|
|
|
username={username}
|
|
|
|
usernameCorrupted={usernameCorrupted}
|
|
|
|
usernameEditState={usernameEditState}
|
|
|
|
usernameLink={usernameLink}
|
|
|
|
usernameLinkColor={usernameLinkColor}
|
|
|
|
usernameLinkCorrupted={usernameLinkCorrupted}
|
|
|
|
usernameLinkState={usernameLinkState}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
});
|