[Glitch] Add default post text to onboarding flow in web UI

Port 8979b70975 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Eugen Rochko 2023-04-28 10:05:34 +02:00 committed by Claire
parent e0b401e295
commit 542f2fb1e0
3 changed files with 10 additions and 7 deletions

View File

@ -145,9 +145,10 @@ export function resetCompose() {
}; };
} }
export const focusCompose = routerHistory => dispatch => { export const focusCompose = (routerHistory, defaultText) => dispatch => {
dispatch({ dispatch({
type: COMPOSE_FOCUS, type: COMPOSE_FOCUS,
defaultText,
}); });
ensureComposeIsVisible(routerHistory); ensureComposeIsVisible(routerHistory);

View File

@ -1,7 +1,7 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React from 'react'; import React from 'react';
import { FormattedMessage } from 'react-intl'; import { FormattedMessage, injectIntl, defineMessages } from 'react-intl';
import { Helmet } from 'react-helmet'; import { Helmet } from 'react-helmet';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
@ -25,7 +25,9 @@ import Step from './components/step';
import Follows from './follows'; import Follows from './follows';
import Share from './share'; import Share from './share';
const messages = defineMessages({
template: { id: 'onboarding.compose.template', defaultMessage: 'Hello #Mastodon!' },
});
const mapStateToProps = () => { const mapStateToProps = () => {
const getAccount = makeGetAccount(); const getAccount = makeGetAccount();
@ -69,10 +71,10 @@ class Onboarding extends ImmutablePureComponent {
}; };
handleComposeClick = () => { handleComposeClick = () => {
const { dispatch } = this.props; const { dispatch, intl } = this.props;
const { router } = this.context; const { router } = this.context;
dispatch(focusCompose(router.history)); dispatch(focusCompose(router.history, intl.formatMessage(messages.template)));
}; };
handleShareClick = () => { handleShareClick = () => {
@ -146,4 +148,4 @@ class Onboarding extends ImmutablePureComponent {
} }
export default connect(mapStateToProps)(Onboarding); export default connect(mapStateToProps)(injectIntl(Onboarding));

View File

@ -653,7 +653,7 @@ export default function compose(state = initialState, action) {
case COMPOSE_LANGUAGE_CHANGE: case COMPOSE_LANGUAGE_CHANGE:
return state.set('language', action.language); return state.set('language', action.language);
case COMPOSE_FOCUS: case COMPOSE_FOCUS:
return state.set('focusDate', new Date()); return state.set('focusDate', new Date()).update('text', text => text.length > 0 ? text : action.defaultText);
default: default:
return state; return state;
} }