Finished updating the reformatting of propTypes and set redux, intl functions to end of component
• Finished: - updating the reformatting of propTypes and set redux, intl functions to end of component • Removed: - Gif implementation
This commit is contained in:
@@ -23,127 +23,8 @@ import { makeGetAccount } from '../../selectors'
|
||||
import PopoverLayout from './popover_layout'
|
||||
import List from '../list'
|
||||
|
||||
const messages = defineMessages({
|
||||
blockAndReport: { id: 'confirmations.block.block_and_report', defaultMessage: 'Block & Report' },
|
||||
unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
|
||||
follow: { id: 'account.follow', defaultMessage: 'Follow' },
|
||||
requested: { id: 'account.requested', defaultMessage: 'Awaiting approval. Click to cancel follow request' },
|
||||
unblock: { id: 'account.unblock', defaultMessage: 'Unblock @{name}' },
|
||||
edit_profile: { id: 'account.edit_profile', defaultMessage: 'Edit profile' },
|
||||
linkVerifiedOn: { id: 'account.link_verified_on', defaultMessage: 'Ownership of this link was checked on {date}' },
|
||||
account_locked: { id: 'account.locked_info', defaultMessage: 'This account privacy status is set to locked. The owner manually reviews who can follow them.' },
|
||||
mention: { id: 'account.mention', defaultMessage: 'Mention' },
|
||||
unmute: { id: 'account.unmute', defaultMessage: 'Unmute @{name}' },
|
||||
block: { id: 'account.block', defaultMessage: 'Block @{name}' },
|
||||
mute: { id: 'account.mute', defaultMessage: 'Mute @{name}' },
|
||||
report: { id: 'account.report', defaultMessage: 'Report @{name}' },
|
||||
share: { id: 'account.share', defaultMessage: 'Share @{name}\'s profile' },
|
||||
media: { id: 'account.media', defaultMessage: 'Media' },
|
||||
hideReposts: { id: 'account.hide_reblogs', defaultMessage: 'Hide reposts from @{name}' },
|
||||
showReposts: { id: 'account.show_reblogs', defaultMessage: 'Show reposts from @{name}' },
|
||||
preferences: { id: 'navigation_bar.preferences', defaultMessage: 'Preferences' },
|
||||
blocks: { id: 'navigation_bar.blocks', defaultMessage: 'Blocked users' },
|
||||
mutes: { id: 'navigation_bar.mutes', defaultMessage: 'Muted users' },
|
||||
admin_account: { id: 'admin_account', defaultMessage: 'Open moderation interface' },
|
||||
add_to_list: { id: 'lists.account.add', defaultMessage: 'Add to list' },
|
||||
add_to_shortcuts: { id: 'account.add_to_shortcuts', defaultMessage: 'Add to shortcuts' },
|
||||
remove_from_shortcuts: { id: 'account.remove_from_shortcuts', defaultMessage: 'Remove from shortcuts' },
|
||||
accountBlocked: { id: 'account.blocked', defaultMessage: 'Blocked' },
|
||||
accountMuted: { id: 'account.muted', defaultMessage: 'Muted' },
|
||||
});
|
||||
|
||||
const mapStateToProps = (state, { account }) => {
|
||||
const getAccount = makeGetAccount()
|
||||
const accountId = !!account ? account.get('id') : -1
|
||||
const shortcuts = state.getIn(['shortcuts', 'items'])
|
||||
const isShortcut = !!shortcuts.find((s) => {
|
||||
return s.get('shortcut_id') == accountId && s.get('shortcut_type') === 'account'
|
||||
})
|
||||
|
||||
return {
|
||||
isShortcut,
|
||||
account: getAccount(state, accountId),
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||
onFollow(account) {
|
||||
if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
|
||||
if (unfollowModal) {
|
||||
dispatch(openModal('UNFOLLOW', {
|
||||
account,
|
||||
}))
|
||||
} else {
|
||||
dispatch(unfollowAccount(account.get('id')))
|
||||
}
|
||||
} else {
|
||||
dispatch(followAccount(account.get('id')))
|
||||
}
|
||||
},
|
||||
onBlock(account) {
|
||||
dispatch(closePopover())
|
||||
|
||||
if (account.getIn(['relationship', 'blocking'])) {
|
||||
dispatch(unblockAccount(account.get('id')));
|
||||
} else {
|
||||
dispatch(openModal('BLOCK_ACCOUNT', {
|
||||
accountId: account.get('id'),
|
||||
}));
|
||||
}
|
||||
},
|
||||
onMention(account) {
|
||||
dispatch(closePopover())
|
||||
dispatch(mentionCompose(account));
|
||||
},
|
||||
onRepostToggle(account) {
|
||||
dispatch(closePopover())
|
||||
if (account.getIn(['relationship', 'showing_reblogs'])) {
|
||||
dispatch(followAccount(account.get('id'), false));
|
||||
} else {
|
||||
dispatch(followAccount(account.get('id'), true));
|
||||
}
|
||||
},
|
||||
onReport(account) {
|
||||
dispatch(closePopover())
|
||||
dispatch(initReport(account));
|
||||
},
|
||||
onMute(account) {
|
||||
dispatch(closePopover())
|
||||
if (account.getIn(['relationship', 'muting'])) {
|
||||
dispatch(unmuteAccount(account.get('id')));
|
||||
} else {
|
||||
dispatch(openModal('MUTE', {
|
||||
accountId: account.get('id'),
|
||||
}))
|
||||
}
|
||||
},
|
||||
onAddToList(account) {
|
||||
dispatch(closePopover())
|
||||
dispatch(openModal('LIST_ADD_USER', {
|
||||
accountId: account.get('id'),
|
||||
}));
|
||||
},
|
||||
onClosePopover: () => dispatch(closePopover()),
|
||||
onAddShortcut(accountId) {
|
||||
dispatch(closePopover())
|
||||
dispatch(addShortcut('account', accountId))
|
||||
},
|
||||
onRemoveShortcut(accountId) {
|
||||
dispatch(closePopover())
|
||||
dispatch(removeShortcut(null, 'account', accountId))
|
||||
},
|
||||
})
|
||||
|
||||
export default
|
||||
@injectIntl
|
||||
@connect(mapStateToProps, mapDispatchToProps)
|
||||
class ProfileOptionsPopover extends React.PureComponent {
|
||||
|
||||
static defaultProps = {
|
||||
isXS: PropTypes.bool,
|
||||
isShortcut: PropTypes.bool,
|
||||
}
|
||||
|
||||
makeMenu() {
|
||||
const {
|
||||
account,
|
||||
@@ -299,4 +180,122 @@ class ProfileOptionsPopover extends React.PureComponent {
|
||||
</PopoverLayout>
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const messages = defineMessages({
|
||||
blockAndReport: { id: 'confirmations.block.block_and_report', defaultMessage: 'Block & Report' },
|
||||
unfollow: { id: 'account.unfollow', defaultMessage: 'Unfollow' },
|
||||
follow: { id: 'account.follow', defaultMessage: 'Follow' },
|
||||
requested: { id: 'account.requested', defaultMessage: 'Awaiting approval. Click to cancel follow request' },
|
||||
unblock: { id: 'account.unblock', defaultMessage: 'Unblock @{name}' },
|
||||
edit_profile: { id: 'account.edit_profile', defaultMessage: 'Edit profile' },
|
||||
linkVerifiedOn: { id: 'account.link_verified_on', defaultMessage: 'Ownership of this link was checked on {date}' },
|
||||
account_locked: { id: 'account.locked_info', defaultMessage: 'This account privacy status is set to locked. The owner manually reviews who can follow them.' },
|
||||
mention: { id: 'account.mention', defaultMessage: 'Mention' },
|
||||
unmute: { id: 'account.unmute', defaultMessage: 'Unmute @{name}' },
|
||||
block: { id: 'account.block', defaultMessage: 'Block @{name}' },
|
||||
mute: { id: 'account.mute', defaultMessage: 'Mute @{name}' },
|
||||
report: { id: 'account.report', defaultMessage: 'Report @{name}' },
|
||||
share: { id: 'account.share', defaultMessage: 'Share @{name}\'s profile' },
|
||||
media: { id: 'account.media', defaultMessage: 'Media' },
|
||||
hideReposts: { id: 'account.hide_reblogs', defaultMessage: 'Hide reposts from @{name}' },
|
||||
showReposts: { id: 'account.show_reblogs', defaultMessage: 'Show reposts from @{name}' },
|
||||
preferences: { id: 'navigation_bar.preferences', defaultMessage: 'Preferences' },
|
||||
blocks: { id: 'navigation_bar.blocks', defaultMessage: 'Blocked users' },
|
||||
mutes: { id: 'navigation_bar.mutes', defaultMessage: 'Muted users' },
|
||||
admin_account: { id: 'admin_account', defaultMessage: 'Open moderation interface' },
|
||||
add_to_list: { id: 'lists.account.add', defaultMessage: 'Add to list' },
|
||||
add_to_shortcuts: { id: 'account.add_to_shortcuts', defaultMessage: 'Add to shortcuts' },
|
||||
remove_from_shortcuts: { id: 'account.remove_from_shortcuts', defaultMessage: 'Remove from shortcuts' },
|
||||
accountBlocked: { id: 'account.blocked', defaultMessage: 'Blocked' },
|
||||
accountMuted: { id: 'account.muted', defaultMessage: 'Muted' },
|
||||
});
|
||||
|
||||
const mapStateToProps = (state, { account }) => {
|
||||
const getAccount = makeGetAccount()
|
||||
const accountId = !!account ? account.get('id') : -1
|
||||
const shortcuts = state.getIn(['shortcuts', 'items'])
|
||||
const isShortcut = !!shortcuts.find((s) => {
|
||||
return s.get('shortcut_id') == accountId && s.get('shortcut_type') === 'account'
|
||||
})
|
||||
|
||||
return {
|
||||
isShortcut,
|
||||
account: getAccount(state, accountId),
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = (dispatch, { intl }) => ({
|
||||
onFollow(account) {
|
||||
if (account.getIn(['relationship', 'following']) || account.getIn(['relationship', 'requested'])) {
|
||||
if (unfollowModal) {
|
||||
dispatch(openModal('UNFOLLOW', {
|
||||
account,
|
||||
}))
|
||||
} else {
|
||||
dispatch(unfollowAccount(account.get('id')))
|
||||
}
|
||||
} else {
|
||||
dispatch(followAccount(account.get('id')))
|
||||
}
|
||||
},
|
||||
onBlock(account) {
|
||||
dispatch(closePopover())
|
||||
|
||||
if (account.getIn(['relationship', 'blocking'])) {
|
||||
dispatch(unblockAccount(account.get('id')));
|
||||
} else {
|
||||
dispatch(openModal('BLOCK_ACCOUNT', {
|
||||
accountId: account.get('id'),
|
||||
}));
|
||||
}
|
||||
},
|
||||
onMention(account) {
|
||||
dispatch(closePopover())
|
||||
dispatch(mentionCompose(account));
|
||||
},
|
||||
onRepostToggle(account) {
|
||||
dispatch(closePopover())
|
||||
if (account.getIn(['relationship', 'showing_reblogs'])) {
|
||||
dispatch(followAccount(account.get('id'), false));
|
||||
} else {
|
||||
dispatch(followAccount(account.get('id'), true));
|
||||
}
|
||||
},
|
||||
onReport(account) {
|
||||
dispatch(closePopover())
|
||||
dispatch(initReport(account));
|
||||
},
|
||||
onMute(account) {
|
||||
dispatch(closePopover())
|
||||
if (account.getIn(['relationship', 'muting'])) {
|
||||
dispatch(unmuteAccount(account.get('id')));
|
||||
} else {
|
||||
dispatch(openModal('MUTE', {
|
||||
accountId: account.get('id'),
|
||||
}))
|
||||
}
|
||||
},
|
||||
onAddToList(account) {
|
||||
dispatch(closePopover())
|
||||
dispatch(openModal('LIST_ADD_USER', {
|
||||
accountId: account.get('id'),
|
||||
}));
|
||||
},
|
||||
onClosePopover: () => dispatch(closePopover()),
|
||||
onAddShortcut(accountId) {
|
||||
dispatch(closePopover())
|
||||
dispatch(addShortcut('account', accountId))
|
||||
},
|
||||
onRemoveShortcut(accountId) {
|
||||
dispatch(closePopover())
|
||||
dispatch(removeShortcut(null, 'account', accountId))
|
||||
},
|
||||
})
|
||||
|
||||
ProfileOptionsPopover.defaultProps = {
|
||||
isXS: PropTypes.bool,
|
||||
isShortcut: PropTypes.bool,
|
||||
}
|
||||
|
||||
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(ProfileOptionsPopover))
|
||||
Reference in New Issue
Block a user