Skip to content

Commit

Permalink
Add default post text to onboarding flow in web UI (mastodon#24705)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron authored and skerit committed Jul 7, 2023
1 parent 22d12e7 commit 295ec1e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion app/javascript/mastodon/actions/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ export function resetCompose() {
};
}

export const focusCompose = routerHistory => dispatch => {
export const focusCompose = (routerHistory, defaultText) => dispatch => {
dispatch({
type: COMPOSE_FOCUS,
defaultText,
});

ensureComposeIsVisible(routerHistory);
Expand Down
12 changes: 8 additions & 4 deletions app/javascript/mastodon/features/onboarding/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ import Follows from './follows';
import Share from './share';
import Step from './components/step';
import ArrowSmallRight from './components/arrow_small_right';
import { FormattedMessage } from 'react-intl';
import { FormattedMessage, injectIntl, defineMessages } from 'react-intl';
import { debounce } from 'lodash';

const messages = defineMessages({
template: { id: 'onboarding.compose.template', defaultMessage: 'Hello #Mastodon!' },
});

const mapStateToProps = () => {
const getAccount = makeGetAccount();

Expand Down Expand Up @@ -61,10 +65,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 = () => {
Expand Down Expand Up @@ -138,4 +142,4 @@ class Onboarding extends ImmutablePureComponent {

}

export default connect(mapStateToProps)(Onboarding);
export default connect(mapStateToProps)(injectIntl(Onboarding));
4 changes: 4 additions & 0 deletions app/javascript/mastodon/locales/defaultMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3211,6 +3211,10 @@
},
{
"descriptors": [
{
"defaultMessage": "Hello #Mastodon!",
"id": "onboarding.compose.template"
},
{
"defaultMessage": "You've made it!",
"id": "onboarding.start.title"
Expand Down
1 change: 1 addition & 0 deletions app/javascript/mastodon/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@
"onboarding.actions.close": "Don't show this screen again",
"onboarding.actions.go_to_explore": "See what's trending",
"onboarding.actions.go_to_home": "Go to your home feed",
"onboarding.compose.template": "Hello #Mastodon!",
"onboarding.follows.empty": "Unfortunately, no results can be shown right now. You can try using search or browsing the explore page to find people to follow, or try again later.",
"onboarding.follows.lead": "You curate your own home feed. The more people you follow, the more active and interesting it will be. These profiles may be a good starting point—you can always unfollow them later!",
"onboarding.follows.title": "Popular on Mastodon",
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/mastodon/reducers/compose.js
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,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;
}
Expand Down

0 comments on commit 295ec1e

Please sign in to comment.