0
0
Fork 0

Refactor initial state: "me" (#5563)

* Refactor initial state: "me"

* remove "me" from reducers/meta.js
This commit is contained in:
Nolan Lawson 2017-10-30 19:27:48 -07:00 committed by Yamagishi Kazutoshi
parent 29609fbb6a
commit b254e6ca5f
24 changed files with 44 additions and 60 deletions

View file

@ -11,6 +11,7 @@ import Search from '../../compose/components/search';
import NavigationBar from '../../compose/components/navigation_bar';
import ColumnHeader from './column_header';
import { List as ImmutableList } from 'immutable';
import { me } from '../../../initial_state';
const noop = () => { };
@ -40,11 +41,11 @@ PageOne.propTypes = {
domain: PropTypes.string.isRequired,
};
const PageTwo = ({ me }) => (
const PageTwo = ({ myAccount }) => (
<div className='onboarding-modal__page onboarding-modal__page-two'>
<div className='figure non-interactive'>
<div className='pseudo-drawer'>
<NavigationBar account={me} />
<NavigationBar account={myAccount} />
</div>
<ComposeForm
text='Awoo! #introductions'
@ -68,10 +69,10 @@ const PageTwo = ({ me }) => (
);
PageTwo.propTypes = {
me: ImmutablePropTypes.map.isRequired,
myAccount: ImmutablePropTypes.map.isRequired,
};
const PageThree = ({ me }) => (
const PageThree = ({ myAccount }) => (
<div className='onboarding-modal__page onboarding-modal__page-three'>
<div className='figure non-interactive'>
<Search
@ -83,7 +84,7 @@ const PageThree = ({ me }) => (
/>
<div className='pseudo-drawer'>
<NavigationBar account={me} />
<NavigationBar account={myAccount} />
</div>
</div>
@ -93,7 +94,7 @@ const PageThree = ({ me }) => (
);
PageThree.propTypes = {
me: ImmutablePropTypes.map.isRequired,
myAccount: ImmutablePropTypes.map.isRequired,
};
const PageFour = ({ domain, intl }) => (
@ -161,7 +162,7 @@ PageSix.propTypes = {
};
const mapStateToProps = state => ({
me: state.getIn(['accounts', state.getIn(['meta', 'me'])]),
myAccount: state.getIn(['accounts', me]),
admin: state.getIn(['accounts', state.getIn(['meta', 'admin'])]),
domain: state.getIn(['meta', 'domain']),
});
@ -173,7 +174,7 @@ export default class OnboardingModal extends React.PureComponent {
static propTypes = {
onClose: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
me: ImmutablePropTypes.map.isRequired,
myAccount: ImmutablePropTypes.map.isRequired,
domain: PropTypes.string.isRequired,
admin: ImmutablePropTypes.map,
};
@ -183,11 +184,11 @@ export default class OnboardingModal extends React.PureComponent {
};
componentWillMount() {
const { me, admin, domain, intl } = this.props;
const { myAccount, admin, domain, intl } = this.props;
this.pages = [
<PageOne acct={me.get('acct')} domain={domain} />,
<PageTwo me={me} />,
<PageThree me={me} />,
<PageOne acct={myAccount.get('acct')} domain={domain} />,
<PageTwo myAccount={myAccount} />,
<PageThree myAccount={myAccount} />,
<PageFour domain={domain} intl={intl} />,
<PageSix admin={admin} domain={domain} />,
];

View file

@ -4,13 +4,13 @@ import { scrollTopTimeline } from '../../../actions/timelines';
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
import { createSelector } from 'reselect';
import { debounce } from 'lodash';
import { me } from '../../../initial_state';
const makeGetStatusIds = () => createSelector([
(state, { type }) => state.getIn(['settings', type], ImmutableMap()),
(state, { type }) => state.getIn(['timelines', type, 'items'], ImmutableList()),
(state) => state.get('statuses'),
(state) => state.getIn(['meta', 'me']),
], (columnSettings, statusIds, statuses, me) => {
], (columnSettings, statusIds, statuses) => {
const rawRegex = columnSettings.getIn(['regex', 'body'], '').trim();
let regex = null;

View file

@ -38,13 +38,13 @@ import {
PinnedStatuses,
} from './util/async-components';
import { HotKeys } from 'react-hotkeys';
import { me } from '../../initial_state';
// Dummy import, to make sure that <Status /> ends up in the application bundle.
// Without this it ends up in ~8 very commonly used bundles.
import '../../components/status';
const mapStateToProps = state => ({
me: state.getIn(['meta', 'me']),
isComposing: state.getIn(['compose', 'is_composing']),
});
@ -86,7 +86,6 @@ export default class UI extends React.Component {
dispatch: PropTypes.func.isRequired,
children: PropTypes.node,
isComposing: PropTypes.bool,
me: PropTypes.string,
location: PropTypes.object,
};
@ -305,7 +304,7 @@ export default class UI extends React.Component {
}
handleHotkeyGoToProfile = () => {
this.context.router.history.push(`/accounts/${this.props.me}`);
this.context.router.history.push(`/accounts/${me}`);
}
handleHotkeyGoToBlocked = () => {