parent
d6a64f45fd
commit
2e7aac793a
@ -0,0 +1,48 @@ |
||||
import api from '../api' |
||||
|
||||
export const ACCOUNT_SET_SELF = 'ACCOUNT_SET_SELF'; |
||||
export const ACCOUNT_FETCH = 'ACCOUNT_FETCH'; |
||||
export const ACCOUNT_FETCH_REQUEST = 'ACCOUNT_FETCH_REQUEST'; |
||||
export const ACCOUNT_FETCH_SUCCESS = 'ACCOUNT_FETCH_SUCCESS'; |
||||
export const ACCOUNT_FETCH_FAIL = 'ACCOUNT_FETCH_FAIL'; |
||||
|
||||
export function setAccountSelf(account) { |
||||
return { |
||||
type: ACCOUNT_SET_SELF, |
||||
account: account |
||||
}; |
||||
}; |
||||
|
||||
export function fetchAccount(id) { |
||||
return (dispatch, getState) => { |
||||
dispatch(fetchAccountRequest(id)); |
||||
|
||||
api(getState).get(`/api/accounts/${id}`).then(response => { |
||||
dispatch(fetchAccountSuccess(response.data)); |
||||
}).catch(error => { |
||||
dispatch(fetchAccountFail(id, error)); |
||||
}); |
||||
}; |
||||
}; |
||||
|
||||
export function fetchAccountRequest(id) { |
||||
return { |
||||
type: ACCOUNT_FETCH_REQUEST, |
||||
id: id |
||||
}; |
||||
}; |
||||
|
||||
export function fetchAccountSuccess(account) { |
||||
return { |
||||
type: ACCOUNT_FETCH_SUCCESS, |
||||
account: account |
||||
}; |
||||
}; |
||||
|
||||
export function fetchAccountFail(id, error) { |
||||
return { |
||||
type: ACCOUNT_FETCH_FAIL, |
||||
id: id, |
||||
error: error |
||||
}; |
||||
}; |
@ -0,0 +1,6 @@ |
||||
import api from '../api'; |
||||
|
||||
export const STATUS_FETCH = 'STATUS_FETCH'; |
||||
export const STATUS_FETCH_REQUEST = 'STATUS_FETCH_REQUEST'; |
||||
export const STATUS_FETCH_SUCCESS = 'STATUS_FETCH_SUCCESS'; |
||||
export const STATUS_FETCH_FAIL = 'STATUS_FETCH_FAIL'; |
@ -0,0 +1,30 @@ |
||||
import PureRenderMixin from 'react-addons-pure-render-mixin'; |
||||
import ImmutablePropTypes from 'react-immutable-proptypes'; |
||||
import Avatar from './avatar'; |
||||
import IconButton from './icon_button'; |
||||
import DisplayName from './display_name'; |
||||
import { Link } from 'react-router'; |
||||
|
||||
const NavigationBar = React.createClass({ |
||||
propTypes: { |
||||
account: ImmutablePropTypes.map.isRequired |
||||
}, |
||||
|
||||
mixins: [PureRenderMixin], |
||||
|
||||
render () { |
||||
return ( |
||||
<div style={{ padding: '10px', display: 'flex', cursor: 'default' }}> |
||||
<Avatar src={this.props.account.get('avatar')} size={40} /> |
||||
|
||||
<div style={{ flex: '1 1 auto', marginLeft: '8px' }}> |
||||
<strong style={{ fontWeight: '500', display: 'block' }}>{this.props.account.get('acct')}</strong> |
||||
<Link to='/settings' style={{ color: '#9baec8', textDecoration: 'none' }}>Settings <i className='fa fa fa-cog' /></Link> |
||||
</div> |
||||
</div> |
||||
); |
||||
} |
||||
|
||||
}); |
||||
|
||||
export default NavigationBar; |
@ -0,0 +1,8 @@ |
||||
import { connect } from 'react-redux'; |
||||
import NavigationBar from '../components/navigation_bar'; |
||||
|
||||
const mapStateToProps = (state, props) => ({ |
||||
account: state.getIn(['timelines', 'accounts', state.getIn(['timelines', 'me'])]) |
||||
}); |
||||
|
||||
export default connect(mapStateToProps)(NavigationBar); |
@ -1,13 +0,0 @@ |
||||
const AccountRoute = React.createClass({ |
||||
|
||||
render() { |
||||
return ( |
||||
<div> |
||||
{this.props.params.account_id} |
||||
</div> |
||||
) |
||||
} |
||||
|
||||
}); |
||||
|
||||
export default AccountRoute; |
@ -1,13 +0,0 @@ |
||||
const StatusRoute = React.createClass({ |
||||
|
||||
render() { |
||||
return ( |
||||
<div> |
||||
{this.props.params.status_id} |
||||
</div> |
||||
) |
||||
} |
||||
|
||||
}); |
||||
|
||||
export default StatusRoute; |
@ -1,2 +1,14 @@ |
||||
module HomeHelper |
||||
def default_props |
||||
{ |
||||
token: @token, |
||||
|
||||
account: render(file: 'api/accounts/show', locals: { account: current_user.account }, formats: :json), |
||||
|
||||
timelines: { |
||||
home: render(file: 'api/statuses/home', locals: { statuses: @home }, formats: :json), |
||||
mentions: render(file: 'api/statuses/mentions', locals: { statuses: @mentions }, formats: :json) |
||||
} |
||||
} |
||||
end |
||||
end |
||||
|
@ -1 +1 @@ |
||||
= react_component 'Root', { token: @token, timelines: { home: render(file: 'api/statuses/home', locals: { statuses: @home }, formats: :json), mentions: render(file: 'api/statuses/mentions', locals: { statuses: @mentions }, formats: :json) }}, class: 'app-holder', prerender: false |
||||
= react_component 'Root', default_props, class: 'app-holder', prerender: false |
||||
|
Loading…
Reference in new issue