diff --git a/app/javascript/mastodon/actions/UtilBtns.js b/app/javascript/mastodon/actions/UtilBtns.js new file mode 100644 index 000000000..ce11fa037 --- /dev/null +++ b/app/javascript/mastodon/actions/UtilBtns.js @@ -0,0 +1,67 @@ +import { changeCompose } from '../actions/compose'; + +export const UTILBTNS_GOJI = 'UTILBTNS_GOJI'; +export const UTILBTNS_HARUKIN = 'UTILBTNS_HARUKIN'; + +export function submitGoji (textarea) { + return function (dispatch, getState) { + if (!textarea.value) { + let text = [ + "#ゴジモリィィィィイイ", + ":goji:" + ].join("\r\n"); + + dispatch(submitGojiRequest()); + dispatch(changeCompose(text)); + + textarea.focus(); + } + } +} + +export function submitGojiRequest () { + return { + type: UTILBTNS_GOJI + } +} + +export function submitHarukin (textarea) { + return function (dispatch, getState) { + const HARUKINS = [":harukin: ", ":harukin_old: ", ":harukin_ika: ", ":harukin_tako: "]; + const MAX = 6; + + if (!textarea.value) { + let text = ""; + + let quantity = Math.round(Math.random() * MAX + 1); + let type = Math.round(Math.random() * (HARUKINS.length - 1)); + + let harukin = HARUKINS[type]; + + switch (quantity) { + default: + text = [ + harukin.repeat(quantity), + "🔥 ".repeat(quantity) + ].join("\r\n"); + + break; + + case MAX + 1: + text = `${harukin}💕\r\n`.repeat(6); + break; + } + + dispatch(submitHarukinRequest()); + dispatch(changeCompose(text)); + + textarea.focus(); + } + } +} + +export function submitHarukinRequest () { + return { + type: UTILBTNS_HARUKIN + } +} \ No newline at end of file diff --git a/app/javascript/mastodon/features/compose/components/compose_form.js b/app/javascript/mastodon/features/compose/components/compose_form.js index a715f8af7..ef60c0a42 100644 --- a/app/javascript/mastodon/features/compose/components/compose_form.js +++ b/app/javascript/mastodon/features/compose/components/compose_form.js @@ -29,6 +29,8 @@ const messages = defineMessages({ publish: { id: 'compose_form.publish', defaultMessage: 'Publish' }, publishLoud: { id: 'compose_form.publish_loud', defaultMessage: '{publish}!' }, saveChanges: { id: 'compose_form.save_changes', defaultMessage: 'Save changes' }, + utilBtns_goji: { id: 'compose_form.utilBtns_goji', defaultMessage: 'Typo!!!' }, + utilBtns_harukin: { id: 'compose_form.utilBtns_harukin', defaultMessage: 'Burn Harukin' } }); export default @injectIntl @@ -65,6 +67,8 @@ class ComposeForm extends ImmutablePureComponent { isInReply: PropTypes.bool, singleColumn: PropTypes.bool, lang: PropTypes.string, + onGojiSubmit: PropTypes.func.isRequired, + onHarukinSubmit: PropTypes.func.isRequired, }; static defaultProps = { @@ -206,6 +210,9 @@ class ComposeForm extends ImmutablePureComponent { this.props.onPickEmoji(position, data, needsSpace); }; + handleOnGojiSubmit = () => this.props.onGojiSubmit(this.autosuggestTextarea.textarea); + handleOnHarukinSubmit = () => this.props.onHarukinSubmit(this.autosuggestTextarea.textarea); + render () { const { intl, onPaste, autoFocus } = this.props; const disabled = this.props.isSubmitting; @@ -293,6 +300,10 @@ class ComposeForm extends ImmutablePureComponent { block /> +