mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-02-09 00:12:13 -05:00
[Glitch] Redirect new users to onboarding
Port e9462960a7cf416b9e459d599a0f2cc8c5b070f0 to glitch-soc Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
563ff91cf8
commit
09bd5aa156
@ -19,7 +19,7 @@ export interface BaseApiAccountJSON {
|
||||
avatar_static: string;
|
||||
bot: boolean;
|
||||
created_at: string;
|
||||
discoverable: boolean;
|
||||
discoverable?: boolean;
|
||||
indexable: boolean;
|
||||
display_name: string;
|
||||
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 PersonIcon from '@/material-icons/400-24px/person.svg?react';
|
||||
import { updateAccount } from 'flavours/glitch/actions/accounts';
|
||||
import { closeOnboarding } from 'flavours/glitch/actions/onboarding';
|
||||
import { Button } from 'flavours/glitch/components/button';
|
||||
import { Column } from 'flavours/glitch/components/column';
|
||||
import { ColumnHeader } from 'flavours/glitch/components/column_header';
|
||||
@ -58,7 +59,9 @@ export const Profile: React.FC<{
|
||||
);
|
||||
const [avatar, setAvatar] = 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 [errors, setErrors] = useState<ApiAccountErrors>();
|
||||
const avatarFileRef = createRef<HTMLInputElement>();
|
||||
@ -132,6 +135,7 @@ export const Profile: React.FC<{
|
||||
)
|
||||
.then(() => {
|
||||
history.push('/start/follows');
|
||||
dispatch(closeOnboarding());
|
||||
return '';
|
||||
})
|
||||
// eslint-disable-next-line @typescript-eslint/use-unknown-in-catch-callback-variable
|
||||
|
@ -100,6 +100,7 @@ const mapStateToProps = state => ({
|
||||
hicolorPrivacyIcons: state.getIn(['local_settings', 'hicolor_privacy_icons']),
|
||||
moved: state.getIn(['accounts', me, 'moved']) && state.getIn(['accounts', state.getIn(['accounts', me, 'moved'])]),
|
||||
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']),
|
||||
});
|
||||
|
||||
@ -144,6 +145,7 @@ class SwitchingColumnsArea extends PureComponent {
|
||||
children: PropTypes.node,
|
||||
location: PropTypes.object,
|
||||
singleColumn: PropTypes.bool,
|
||||
forceOnboarding: PropTypes.bool,
|
||||
};
|
||||
|
||||
UNSAFE_componentWillMount () {
|
||||
@ -174,14 +176,16 @@ class SwitchingColumnsArea extends PureComponent {
|
||||
};
|
||||
|
||||
render () {
|
||||
const { children, singleColumn } = this.props;
|
||||
const { children, singleColumn, forceOnboarding } = this.props;
|
||||
const { signedIn } = this.props.identity;
|
||||
const pathName = this.props.location.pathname;
|
||||
|
||||
let redirect;
|
||||
|
||||
if (signedIn) {
|
||||
if (singleColumn) {
|
||||
if (forceOnboarding) {
|
||||
redirect = <Redirect from='/' to='/start' exact />;
|
||||
} else if (singleColumn) {
|
||||
redirect = <Redirect from='/' to='/home' exact />;
|
||||
} else {
|
||||
redirect = <Redirect from='/' to='/deck/getting-started' exact />;
|
||||
@ -292,6 +296,7 @@ class UI extends PureComponent {
|
||||
moved: PropTypes.map,
|
||||
layout: PropTypes.string.isRequired,
|
||||
firstLaunch: PropTypes.bool,
|
||||
newAccount: PropTypes.bool,
|
||||
username: PropTypes.string,
|
||||
...WithRouterPropTypes,
|
||||
};
|
||||
@ -615,7 +620,7 @@ class UI extends PureComponent {
|
||||
|
||||
render () {
|
||||
const { draggingOver } = this.state;
|
||||
const { children, isWide, location, layout, moved } = this.props;
|
||||
const { children, isWide, location, layout, moved, firstLaunch, newAccount } = this.props;
|
||||
|
||||
const className = classNames('ui', {
|
||||
'wide': isWide,
|
||||
@ -662,7 +667,7 @@ class UI extends PureComponent {
|
||||
|
||||
<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}
|
||||
</SwitchingColumnsArea>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user