Fixed issue with account follow button not displaying properly
• Fixed: - issue with account follow button not displaying properly (after removing relationship fetching in notifications and timelines)
This commit is contained in:
parent
5e82d71a9f
commit
19a7d2f31a
|
@ -6,6 +6,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component'
|
|||
import { NavLink } from 'react-router-dom'
|
||||
import { FormattedMessage } from 'react-intl'
|
||||
import { makeGetAccount } from '../../selectors'
|
||||
import { fetchRelationships } from '../../actions/accounts'
|
||||
import { shortNumberFormat } from '../../utils/numbers'
|
||||
import { me } from '../../initial_state'
|
||||
import PopoverLayout from './popover_layout'
|
||||
|
@ -16,6 +17,24 @@ import UserStat from '../user_stat'
|
|||
|
||||
class UserInfoPopover extends ImmutablePureComponent {
|
||||
|
||||
componentDidMount() {
|
||||
this.checkRelationships(this.props.account)
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
const { account } = this.props
|
||||
if (prevProps.account !== account) {
|
||||
this.checkRelationships(account)
|
||||
}
|
||||
}
|
||||
|
||||
checkRelationships = (account) => {
|
||||
if (!account) return
|
||||
if (!account.get('relationship')) {
|
||||
this.props.onFetchRelationships(account.get('id'))
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { account, isXS } = this.props
|
||||
|
||||
|
@ -72,10 +91,16 @@ const mapStateToProps = (state, props) => ({
|
|||
account: makeGetAccount()(state, props.accountId),
|
||||
})
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
onFetchRelationships(accountId) {
|
||||
dispatch(fetchRelationships([accountId]))
|
||||
},
|
||||
})
|
||||
|
||||
UserInfoPopover.propTypes = {
|
||||
account: ImmutablePropTypes.map,
|
||||
accountId: PropTypes.string.isRequired,
|
||||
isXS: PropTypes.bool,
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps)(UserInfoPopover)
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(UserInfoPopover)
|
|
@ -12,6 +12,9 @@ import {
|
|||
MODAL_EDIT_PROFILE,
|
||||
BREAKPOINT_EXTRA_SMALL,
|
||||
} from '../constants'
|
||||
import {
|
||||
fetchRelationships,
|
||||
} from '../actions/accounts'
|
||||
import {
|
||||
addShortcut,
|
||||
removeShortcut,
|
||||
|
@ -41,6 +44,24 @@ class ProfileHeader extends ImmutablePureComponent {
|
|||
stickied: false,
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.checkRelationships(this.props.account)
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps) {
|
||||
const { account } = this.props
|
||||
if (prevProps.account !== account) {
|
||||
this.checkRelationships(account)
|
||||
}
|
||||
}
|
||||
|
||||
checkRelationships = (account) => {
|
||||
if (!account) return
|
||||
if (!account.get('relationship')) {
|
||||
this.props.onFetchRelationships(account.get('id'))
|
||||
}
|
||||
}
|
||||
|
||||
handleOnEditProfile = () => {
|
||||
this.props.onEditProfile()
|
||||
}
|
||||
|
@ -447,6 +468,9 @@ const mapDispatchToProps = (dispatch) => ({
|
|||
onCreateChatConversation(accountId, routerHistory) {
|
||||
dispatch(createChatConversation(accountId, routerHistory))
|
||||
},
|
||||
onFetchRelationships(accountId) {
|
||||
dispatch(fetchRelationships([accountId]))
|
||||
},
|
||||
});
|
||||
|
||||
ProfileHeader.propTypes = {
|
||||
|
|
Loading…
Reference in New Issue