diff --git a/app/javascript/flavours/glitch/actions/compose.js b/app/javascript/flavours/glitch/actions/compose.js index 350ee6fbbe..06f0d79874 100644 --- a/app/javascript/flavours/glitch/actions/compose.js +++ b/app/javascript/flavours/glitch/actions/compose.js @@ -21,7 +21,6 @@ let fetchComposeSuggestionsAccountsController; let fetchComposeSuggestionsTagsController; export const COMPOSE_CHANGE = 'COMPOSE_CHANGE'; -export const COMPOSE_CYCLE_ELEFRIEND = 'COMPOSE_CYCLE_ELEFRIEND'; export const COMPOSE_SUBMIT_REQUEST = 'COMPOSE_SUBMIT_REQUEST'; export const COMPOSE_SUBMIT_SUCCESS = 'COMPOSE_SUBMIT_SUCCESS'; export const COMPOSE_SUBMIT_FAIL = 'COMPOSE_SUBMIT_FAIL'; @@ -117,12 +116,6 @@ export function changeCompose(text) { }; } -export function cycleElefriendCompose() { - return { - type: COMPOSE_CYCLE_ELEFRIEND, - }; -} - export function replyCompose(status, routerHistory) { return (dispatch, getState) => { const prependCWRe = getState().getIn(['local_settings', 'prepend_cw_re']); diff --git a/app/javascript/flavours/glitch/features/compose/index.jsx b/app/javascript/flavours/glitch/features/compose/index.jsx index fe81787fa8..35743bbd16 100644 --- a/app/javascript/flavours/glitch/features/compose/index.jsx +++ b/app/javascript/flavours/glitch/features/compose/index.jsx @@ -21,6 +21,9 @@ import PublicIcon from '@/material-icons/400-24px/public.svg?react'; import { openModal } from 'flavours/glitch/actions/modal'; import Column from 'flavours/glitch/components/column'; import { Icon } from 'flavours/glitch/components/icon'; +import glitchedElephant1 from 'flavours/glitch/images/mbstobon-ui-0.png'; +import glitchedElephant2 from 'flavours/glitch/images/mbstobon-ui-1.png'; +import glitchedElephant3 from 'flavours/glitch/images/mbstobon-ui-2.png'; import { logOut } from 'flavours/glitch/utils/log_out'; import elephantUIPlane from '../../../../images/elephant_ui_plane.svg'; @@ -51,6 +54,11 @@ const mapStateToProps = (state, ownProps) => ({ showSearch: ownProps.multiColumn ? state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']) : false, }); +// ~4% chance you'll end up with an unexpected friend +// glitch-soc/mastodon repo created_at date: 2017-04-20T21:55:28Z +const glitchProbability = 1 - 0.0420215528; +const totalElefriends = 3; + class Compose extends PureComponent { static propTypes = { @@ -61,6 +69,10 @@ class Compose extends PureComponent { intl: PropTypes.object.isRequired, }; + state = { + elefriend: Math.random() < glitchProbability ? Math.floor(Math.random() * totalElefriends) : totalElefriends, + }; + componentDidMount () { const { dispatch } = this.props; dispatch(mountCompose()); @@ -107,9 +119,15 @@ class Compose extends PureComponent { this.props.dispatch(changeComposing(false)); }; + cycleElefriend = () => { + this.setState((state) => ({ elefriend: (state.elefriend + 1) % totalElefriends })); + }; + render () { const { multiColumn, showSearch, intl } = this.props; + const elefriend = [glitchedElephant1, glitchedElephant2, glitchedElephant3, elephantUIPlane][this.state.elefriend]; + if (multiColumn) { const { columns } = this.props; @@ -147,8 +165,9 @@ class Compose extends PureComponent {