Username onboarding

This commit is contained in:
Fedor Indutny 2023-02-13 10:51:41 -08:00 committed by GitHub
parent 5626cea9c3
commit f9aaf30a32
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 309 additions and 3 deletions

View file

@ -8,10 +8,15 @@ import { mapDispatchToProps } from '../actions';
import type { PropsDataType as ProfileEditorModalPropsType } from '../../components/ProfileEditorModal';
import { ProfileEditorModal } from '../../components/ProfileEditorModal';
import type { PropsDataType } from '../../components/ProfileEditor';
import { storageServiceUploadJob } from '../../services/storage';
import { SmartEditUsernameModalBody } from './EditUsernameModalBody';
import type { StateType } from '../reducer';
import { getIntl } from '../selectors/user';
import { getEmojiSkinTone, getUsernamesEnabled } from '../selectors/items';
import {
getEmojiSkinTone,
getUsernamesEnabled,
getHasCompletedUsernameOnboarding,
} from '../selectors/items';
import { getMe } from '../selectors/conversations';
import { selectRecentEmojis } from '../selectors/emojis';
import { getUsernameEditState } from '../selectors/username';
@ -22,6 +27,12 @@ function renderEditUsernameModalBody(props: {
return <SmartEditUsernameModalBody {...props} />;
}
async function markCompletedUsernameOnboarding(): Promise<void> {
await window.storage.put('hasCompletedUsernameOnboarding', true);
storageServiceUploadJob();
}
function mapStateToProps(
state: StateType
): Omit<PropsDataType, 'onEditStateChange' | 'onProfileChanged'> &
@ -40,6 +51,8 @@ function mapStateToProps(
const recentEmojis = selectRecentEmojis(state);
const skinTone = getEmojiSkinTone(state);
const isUsernameFlagEnabled = getUsernamesEnabled(state);
const hasCompletedUsernameOnboarding =
getHasCompletedUsernameOnboarding(state);
const usernameEditState = getUsernameEditState(state);
return {
@ -50,9 +63,11 @@ function mapStateToProps(
conversationId,
familyName,
firstName: String(firstName),
hasCompletedUsernameOnboarding,
hasError: state.globalModals.profileEditorHasError,
i18n: getIntl(state),
isUsernameFlagEnabled,
markCompletedUsernameOnboarding,
recentEmojis,
skinTone,
userAvatarData,