Redirect new users to onboarding (#33471)
This commit is contained in:
		
							parent
							
								
									e2f085e2b2
								
							
						
					
					
						commit
						e9462960a7
					
				|  | @ -19,7 +19,7 @@ export interface BaseApiAccountJSON { | ||||||
|   avatar_static: string; |   avatar_static: string; | ||||||
|   bot: boolean; |   bot: boolean; | ||||||
|   created_at: string; |   created_at: string; | ||||||
|   discoverable: boolean; |   discoverable?: boolean; | ||||||
|   indexable: boolean; |   indexable: boolean; | ||||||
|   display_name: string; |   display_name: string; | ||||||
|   emojis: ApiCustomEmojiJSON[]; |   emojis: ApiCustomEmojiJSON[]; | ||||||
|  |  | ||||||
|  | @ -12,6 +12,7 @@ import AddPhotoAlternateIcon from '@/material-icons/400-24px/add_photo_alternate | ||||||
| import EditIcon from '@/material-icons/400-24px/edit.svg?react'; | import EditIcon from '@/material-icons/400-24px/edit.svg?react'; | ||||||
| import PersonIcon from '@/material-icons/400-24px/person.svg?react'; | import PersonIcon from '@/material-icons/400-24px/person.svg?react'; | ||||||
| import { updateAccount } from 'mastodon/actions/accounts'; | import { updateAccount } from 'mastodon/actions/accounts'; | ||||||
|  | import { closeOnboarding } from 'mastodon/actions/onboarding'; | ||||||
| import { Button } from 'mastodon/components/button'; | import { Button } from 'mastodon/components/button'; | ||||||
| import { Column } from 'mastodon/components/column'; | import { Column } from 'mastodon/components/column'; | ||||||
| import { ColumnHeader } from 'mastodon/components/column_header'; | import { ColumnHeader } from 'mastodon/components/column_header'; | ||||||
|  | @ -58,7 +59,9 @@ export const Profile: React.FC<{ | ||||||
|   ); |   ); | ||||||
|   const [avatar, setAvatar] = useState<File>(); |   const [avatar, setAvatar] = useState<File>(); | ||||||
|   const [header, setHeader] = useState<File>(); |   const [header, setHeader] = useState<File>(); | ||||||
|   const [discoverable, setDiscoverable] = useState(true); |   const [discoverable, setDiscoverable] = useState( | ||||||
|  |     account?.discoverable ?? true, | ||||||
|  |   ); | ||||||
|   const [isSaving, setIsSaving] = useState(false); |   const [isSaving, setIsSaving] = useState(false); | ||||||
|   const [errors, setErrors] = useState<ApiAccountErrors>(); |   const [errors, setErrors] = useState<ApiAccountErrors>(); | ||||||
|   const avatarFileRef = createRef<HTMLInputElement>(); |   const avatarFileRef = createRef<HTMLInputElement>(); | ||||||
|  | @ -132,6 +135,7 @@ export const Profile: React.FC<{ | ||||||
|     ) |     ) | ||||||
|       .then(() => { |       .then(() => { | ||||||
|         history.push('/start/follows'); |         history.push('/start/follows'); | ||||||
|  |         dispatch(closeOnboarding()); | ||||||
|         return ''; |         return ''; | ||||||
|       }) |       }) | ||||||
|       // eslint-disable-next-line @typescript-eslint/use-unknown-in-catch-callback-variable
 |       // eslint-disable-next-line @typescript-eslint/use-unknown-in-catch-callback-variable
 | ||||||
|  |  | ||||||
|  | @ -92,6 +92,7 @@ const mapStateToProps = state => ({ | ||||||
|   hasMediaAttachments: state.getIn(['compose', 'media_attachments']).size > 0, |   hasMediaAttachments: state.getIn(['compose', 'media_attachments']).size > 0, | ||||||
|   canUploadMore: !state.getIn(['compose', 'media_attachments']).some(x => ['audio', 'video'].includes(x.get('type'))) && state.getIn(['compose', 'media_attachments']).size < state.getIn(['server', 'server', 'configuration', 'statuses', 'max_media_attachments']), |   canUploadMore: !state.getIn(['compose', 'media_attachments']).some(x => ['audio', 'video'].includes(x.get('type'))) && state.getIn(['compose', 'media_attachments']).size < state.getIn(['server', 'server', 'configuration', 'statuses', 'max_media_attachments']), | ||||||
|   firstLaunch: state.getIn(['settings', 'introductionVersion'], 0) < INTRODUCTION_VERSION, |   firstLaunch: state.getIn(['settings', 'introductionVersion'], 0) < INTRODUCTION_VERSION, | ||||||
|  |   newAccount: !state.getIn(['accounts', me, 'note']) && !state.getIn(['accounts', me, 'bot']) && state.getIn(['accounts', me, 'following_count'], 0) === 0 && state.getIn(['accounts', me, 'statuses_count'], 0) === 0, | ||||||
|   username: state.getIn(['accounts', me, 'username']), |   username: state.getIn(['accounts', me, 'username']), | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
|  | @ -135,6 +136,7 @@ class SwitchingColumnsArea extends PureComponent { | ||||||
|     children: PropTypes.node, |     children: PropTypes.node, | ||||||
|     location: PropTypes.object, |     location: PropTypes.object, | ||||||
|     singleColumn: PropTypes.bool, |     singleColumn: PropTypes.bool, | ||||||
|  |     forceOnboarding: PropTypes.bool, | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   UNSAFE_componentWillMount () { |   UNSAFE_componentWillMount () { | ||||||
|  | @ -165,14 +167,16 @@ class SwitchingColumnsArea extends PureComponent { | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   render () { |   render () { | ||||||
|     const { children, singleColumn } = this.props; |     const { children, singleColumn, forceOnboarding } = this.props; | ||||||
|     const { signedIn } = this.props.identity; |     const { signedIn } = this.props.identity; | ||||||
|     const pathName = this.props.location.pathname; |     const pathName = this.props.location.pathname; | ||||||
| 
 | 
 | ||||||
|     let redirect; |     let redirect; | ||||||
| 
 | 
 | ||||||
|     if (signedIn) { |     if (signedIn) { | ||||||
|       if (singleColumn) { |       if (forceOnboarding) { | ||||||
|  |         redirect = <Redirect from='/' to='/start' exact />; | ||||||
|  |       } else if (singleColumn) { | ||||||
|         redirect = <Redirect from='/' to='/home' exact />; |         redirect = <Redirect from='/' to='/home' exact />; | ||||||
|       } else { |       } else { | ||||||
|         redirect = <Redirect from='/' to='/deck/getting-started' exact />; |         redirect = <Redirect from='/' to='/deck/getting-started' exact />; | ||||||
|  | @ -276,6 +280,7 @@ class UI extends PureComponent { | ||||||
|     intl: PropTypes.object.isRequired, |     intl: PropTypes.object.isRequired, | ||||||
|     layout: PropTypes.string.isRequired, |     layout: PropTypes.string.isRequired, | ||||||
|     firstLaunch: PropTypes.bool, |     firstLaunch: PropTypes.bool, | ||||||
|  |     newAccount: PropTypes.bool, | ||||||
|     username: PropTypes.string, |     username: PropTypes.string, | ||||||
|     ...WithRouterPropTypes, |     ...WithRouterPropTypes, | ||||||
|   }; |   }; | ||||||
|  | @ -568,7 +573,7 @@ class UI extends PureComponent { | ||||||
| 
 | 
 | ||||||
|   render () { |   render () { | ||||||
|     const { draggingOver } = this.state; |     const { draggingOver } = this.state; | ||||||
|     const { children, isComposing, location, layout } = this.props; |     const { children, isComposing, location, layout, firstLaunch, newAccount } = this.props; | ||||||
| 
 | 
 | ||||||
|     const handlers = { |     const handlers = { | ||||||
|       help: this.handleHotkeyToggleHelp, |       help: this.handleHotkeyToggleHelp, | ||||||
|  | @ -597,7 +602,7 @@ class UI extends PureComponent { | ||||||
|         <div className={classNames('ui', { 'is-composing': isComposing })} ref={this.setRef}> |         <div className={classNames('ui', { 'is-composing': isComposing })} ref={this.setRef}> | ||||||
|           <Header /> |           <Header /> | ||||||
| 
 | 
 | ||||||
|           <SwitchingColumnsArea identity={this.props.identity} location={location} singleColumn={layout === 'mobile' || layout === 'single-column'}> |           <SwitchingColumnsArea identity={this.props.identity} location={location} singleColumn={layout === 'mobile' || layout === 'single-column'} forceOnboarding={firstLaunch && newAccount}> | ||||||
|             {children} |             {children} | ||||||
|           </SwitchingColumnsArea> |           </SwitchingColumnsArea> | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue