From 542f2fb1e0d61e6a618ef7820832555fa8f19050 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Fri, 28 Apr 2023 10:05:34 +0200 Subject: [PATCH] [Glitch] Add default post text to onboarding flow in web UI Port 8979b709750493763368bca9b2fac79902086f48 to glitch-soc Signed-off-by: Claire --- app/javascript/flavours/glitch/actions/compose.js | 3 ++- .../flavours/glitch/features/onboarding/index.jsx | 12 +++++++----- app/javascript/flavours/glitch/reducers/compose.js | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/javascript/flavours/glitch/actions/compose.js b/app/javascript/flavours/glitch/actions/compose.js index d196c340d1..8242ec6c84 100644 --- a/app/javascript/flavours/glitch/actions/compose.js +++ b/app/javascript/flavours/glitch/actions/compose.js @@ -145,9 +145,10 @@ export function resetCompose() { }; } -export const focusCompose = routerHistory => dispatch => { +export const focusCompose = (routerHistory, defaultText) => dispatch => { dispatch({ type: COMPOSE_FOCUS, + defaultText, }); ensureComposeIsVisible(routerHistory); diff --git a/app/javascript/flavours/glitch/features/onboarding/index.jsx b/app/javascript/flavours/glitch/features/onboarding/index.jsx index 5536db4292..aa32e42ccf 100644 --- a/app/javascript/flavours/glitch/features/onboarding/index.jsx +++ b/app/javascript/flavours/glitch/features/onboarding/index.jsx @@ -1,7 +1,7 @@ import PropTypes from 'prop-types'; import React from 'react'; -import { FormattedMessage } from 'react-intl'; +import { FormattedMessage, injectIntl, defineMessages } from 'react-intl'; import { Helmet } from 'react-helmet'; import { Link } from 'react-router-dom'; @@ -25,7 +25,9 @@ import Step from './components/step'; import Follows from './follows'; import Share from './share'; - +const messages = defineMessages({ + template: { id: 'onboarding.compose.template', defaultMessage: 'Hello #Mastodon!' }, +}); const mapStateToProps = () => { const getAccount = makeGetAccount(); @@ -69,10 +71,10 @@ class Onboarding extends ImmutablePureComponent { }; handleComposeClick = () => { - const { dispatch } = this.props; + const { dispatch, intl } = this.props; const { router } = this.context; - dispatch(focusCompose(router.history)); + dispatch(focusCompose(router.history, intl.formatMessage(messages.template))); }; handleShareClick = () => { @@ -146,4 +148,4 @@ class Onboarding extends ImmutablePureComponent { } -export default connect(mapStateToProps)(Onboarding); +export default connect(mapStateToProps)(injectIntl(Onboarding)); diff --git a/app/javascript/flavours/glitch/reducers/compose.js b/app/javascript/flavours/glitch/reducers/compose.js index 9effe7f194..96e5a2d7a3 100644 --- a/app/javascript/flavours/glitch/reducers/compose.js +++ b/app/javascript/flavours/glitch/reducers/compose.js @@ -653,7 +653,7 @@ export default function compose(state = initialState, action) { case COMPOSE_LANGUAGE_CHANGE: return state.set('language', action.language); 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: return state; }