Set glitchy elephant friend variant in initial state. #294.

Also lay some groundwork needed to interactively change the
glitchfriend.

The codebase uses "elefriend" because it's shorter and didn't require me
to realign the actions in actions/compose.js.  Same idea, though.
This commit is contained in:
David Yip 2018-01-13 21:22:37 -06:00
parent 1e0b707018
commit 1dbb6b5e08
No known key found for this signature in database
GPG Key ID: 7DA0036508FCC0CC
8 changed files with 22 additions and 7 deletions

View File

@ -12,6 +12,7 @@ import {
} from './timelines'; } from './timelines';
export const COMPOSE_CHANGE = 'COMPOSE_CHANGE'; 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_REQUEST = 'COMPOSE_SUBMIT_REQUEST';
export const COMPOSE_SUBMIT_SUCCESS = 'COMPOSE_SUBMIT_SUCCESS'; export const COMPOSE_SUBMIT_SUCCESS = 'COMPOSE_SUBMIT_SUCCESS';
export const COMPOSE_SUBMIT_FAIL = 'COMPOSE_SUBMIT_FAIL'; export const COMPOSE_SUBMIT_FAIL = 'COMPOSE_SUBMIT_FAIL';
@ -54,6 +55,12 @@ export function changeCompose(text) {
}; };
}; };
export function cycleElefriendCompose() {
return {
type: COMPOSE_CYCLE_ELEFRIEND,
};
};
export function replyCompose(status, router) { export function replyCompose(status, router) {
return (dispatch, getState) => { return (dispatch, getState) => {
dispatch({ dispatch({

View File

@ -28,6 +28,7 @@ import { wrap } from 'flavours/glitch/util/redux_helpers';
const mapStateToProps = state => ({ const mapStateToProps = state => ({
account: state.getIn(['accounts', me]), account: state.getIn(['accounts', me]),
columns: state.getIn(['settings', 'columns']), columns: state.getIn(['settings', 'columns']),
elefriend: state.getIn(['compose', 'elefriend']),
results: state.getIn(['search', 'results']), results: state.getIn(['search', 'results']),
searchHidden: state.getIn(['search', 'hidden']), searchHidden: state.getIn(['search', 'hidden']),
searchValue: state.getIn(['search', 'value']), searchValue: state.getIn(['search', 'value']),
@ -56,6 +57,7 @@ class Drawer extends React.Component {
const { const {
account, account,
columns, columns,
elefriend,
intl, intl,
multiColumn, multiColumn,
onChange, onChange,
@ -69,10 +71,8 @@ class Drawer extends React.Component {
submitted, submitted,
} = this.props; } = this.props;
let choices = ['mbstobon-bg-1', 'mbstobon-bg-2', 'mbstobon-bg-3']; let elefriendAttrs = {
let glitchyFriendDecision = choices[Math.floor(Math.random() * choices.length)]; className: classNames('mastodon', 'mbstobon-' + elefriend),
let drawerAttrs = {
className: classNames('contents', glitchyFriendDecision)
}; };
// The result. // The result.
@ -98,7 +98,7 @@ class Drawer extends React.Component {
<DrawerAccount account={account} /> <DrawerAccount account={account} />
<div className='drawer__inner'> <div className='drawer__inner'>
<Composer /> <Composer />
{multiColumn && <div className="mastodon mbstobon-bg-1" />} {multiColumn && <div {...elefriendAttrs} />}
</div> </div>
<DrawerResults <DrawerResults
results={results} results={results}
@ -120,6 +120,7 @@ Drawer.propTypes = {
account: ImmutablePropTypes.map, account: ImmutablePropTypes.map,
columns: ImmutablePropTypes.list, columns: ImmutablePropTypes.list,
results: ImmutablePropTypes.map, results: ImmutablePropTypes.map,
elefriend: PropTypes.number,
searchHidden: PropTypes.bool, searchHidden: PropTypes.bool,
searchValue: PropTypes.string, searchValue: PropTypes.string,
submitted: PropTypes.bool, submitted: PropTypes.bool,

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

View File

@ -2,6 +2,7 @@ import {
COMPOSE_MOUNT, COMPOSE_MOUNT,
COMPOSE_UNMOUNT, COMPOSE_UNMOUNT,
COMPOSE_CHANGE, COMPOSE_CHANGE,
COMPOSE_CYCLE_ELEFRIEND,
COMPOSE_REPLY, COMPOSE_REPLY,
COMPOSE_REPLY_CANCEL, COMPOSE_REPLY_CANCEL,
COMPOSE_MENTION, COMPOSE_MENTION,
@ -35,6 +36,8 @@ import uuid from 'flavours/glitch/util/uuid';
import { me } from 'flavours/glitch/util/initial_state'; import { me } from 'flavours/glitch/util/initial_state';
import { overwrite } from 'flavours/glitch/util/js_helpers'; import { overwrite } from 'flavours/glitch/util/js_helpers';
const totalElefriends = 3;
const initialState = ImmutableMap({ const initialState = ImmutableMap({
mounted: false, mounted: false,
advanced_options: ImmutableMap({ advanced_options: ImmutableMap({
@ -42,6 +45,7 @@ const initialState = ImmutableMap({
threaded_mode: false, threaded_mode: false,
}), }),
sensitive: false, sensitive: false,
elefriend: Math.floor(Math.random() * totalElefriends),
spoiler: false, spoiler: false,
spoiler_text: '', spoiler_text: '',
privacy: null, privacy: null,
@ -259,6 +263,9 @@ export default function compose(state = initialState, action) {
return state return state
.set('text', action.text) .set('text', action.text)
.set('idempotencyKey', uuid()); .set('idempotencyKey', uuid());
case COMPOSE_CYCLE_ELEFRIEND:
return state
.set('elefriend', (state.get('elefriend') + 1) % totalElefriends);
case COMPOSE_REPLY: case COMPOSE_REPLY:
return state.withMutations(map => { return state.withMutations(map => {
map.set('in_reply_to', action.status.get('id')); map.set('in_reply_to', action.status.get('id'));

View File

@ -66,8 +66,8 @@
.mastodon { .mastodon {
flex: 1; flex: 1;
@for $i from 1 through 3 { @for $i from 0 through 2 {
&.mbstobon-bg-#{$i} { &.mbstobon-#{$i} {
background: url("~flavours/glitch/images/mbstobon-ui-#{$i}.png") no-repeat left bottom / contain; background: url("~flavours/glitch/images/mbstobon-ui-#{$i}.png") no-repeat left bottom / contain;
} }
} }