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 { NavLink } from 'react-router-dom'
|
||||||
import { FormattedMessage } from 'react-intl'
|
import { FormattedMessage } from 'react-intl'
|
||||||
import { makeGetAccount } from '../../selectors'
|
import { makeGetAccount } from '../../selectors'
|
||||||
|
import { fetchRelationships } from '../../actions/accounts'
|
||||||
import { shortNumberFormat } from '../../utils/numbers'
|
import { shortNumberFormat } from '../../utils/numbers'
|
||||||
import { me } from '../../initial_state'
|
import { me } from '../../initial_state'
|
||||||
import PopoverLayout from './popover_layout'
|
import PopoverLayout from './popover_layout'
|
||||||
@ -16,6 +17,24 @@ import UserStat from '../user_stat'
|
|||||||
|
|
||||||
class UserInfoPopover extends ImmutablePureComponent {
|
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() {
|
render() {
|
||||||
const { account, isXS } = this.props
|
const { account, isXS } = this.props
|
||||||
|
|
||||||
@ -72,10 +91,16 @@ const mapStateToProps = (state, props) => ({
|
|||||||
account: makeGetAccount()(state, props.accountId),
|
account: makeGetAccount()(state, props.accountId),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
|
onFetchRelationships(accountId) {
|
||||||
|
dispatch(fetchRelationships([accountId]))
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
UserInfoPopover.propTypes = {
|
UserInfoPopover.propTypes = {
|
||||||
account: ImmutablePropTypes.map,
|
account: ImmutablePropTypes.map,
|
||||||
accountId: PropTypes.string.isRequired,
|
accountId: PropTypes.string.isRequired,
|
||||||
isXS: PropTypes.bool,
|
isXS: PropTypes.bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps)(UserInfoPopover)
|
export default connect(mapStateToProps, mapDispatchToProps)(UserInfoPopover)
|
@ -12,6 +12,9 @@ import {
|
|||||||
MODAL_EDIT_PROFILE,
|
MODAL_EDIT_PROFILE,
|
||||||
BREAKPOINT_EXTRA_SMALL,
|
BREAKPOINT_EXTRA_SMALL,
|
||||||
} from '../constants'
|
} from '../constants'
|
||||||
|
import {
|
||||||
|
fetchRelationships,
|
||||||
|
} from '../actions/accounts'
|
||||||
import {
|
import {
|
||||||
addShortcut,
|
addShortcut,
|
||||||
removeShortcut,
|
removeShortcut,
|
||||||
@ -41,6 +44,24 @@ class ProfileHeader extends ImmutablePureComponent {
|
|||||||
stickied: false,
|
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 = () => {
|
handleOnEditProfile = () => {
|
||||||
this.props.onEditProfile()
|
this.props.onEditProfile()
|
||||||
}
|
}
|
||||||
@ -447,6 +468,9 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
onCreateChatConversation(accountId, routerHistory) {
|
onCreateChatConversation(accountId, routerHistory) {
|
||||||
dispatch(createChatConversation(accountId, routerHistory))
|
dispatch(createChatConversation(accountId, routerHistory))
|
||||||
},
|
},
|
||||||
|
onFetchRelationships(accountId) {
|
||||||
|
dispatch(fetchRelationships([accountId]))
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
ProfileHeader.propTypes = {
|
ProfileHeader.propTypes = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user