2020-08-17 21:07:16 +01:00
|
|
|
import React from 'react'
|
2020-08-17 21:59:29 +01:00
|
|
|
import PropTypes from 'prop-types'
|
2020-08-17 21:39:25 +01:00
|
|
|
import { connect } from 'react-redux'
|
2020-03-26 03:11:32 +00:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'
|
|
|
|
import ImmutablePureComponent from 'react-immutable-pure-component'
|
2020-05-07 00:40:54 +01:00
|
|
|
import { FormattedMessage, defineMessages, injectIntl } from 'react-intl'
|
|
|
|
import { me, isStaff, boostModal, deleteModal } from '../../initial_state'
|
2020-11-25 21:22:37 +00:00
|
|
|
import { makeGetStatus } from '../../selectors'
|
2020-05-07 00:40:54 +01:00
|
|
|
import {
|
|
|
|
repost,
|
|
|
|
unrepost,
|
|
|
|
pin,
|
|
|
|
unpin,
|
2020-11-25 21:22:37 +00:00
|
|
|
isPin,
|
2020-07-25 00:48:31 +01:00
|
|
|
bookmark,
|
|
|
|
unbookmark,
|
2020-11-25 21:22:37 +00:00
|
|
|
isBookmark,
|
2020-05-07 00:40:54 +01:00
|
|
|
} from '../../actions/interactions';
|
2020-12-21 23:30:46 +00:00
|
|
|
import {
|
|
|
|
muteAccount,
|
|
|
|
unmuteAccount,
|
2020-12-22 17:11:22 +00:00
|
|
|
} from '../../actions/accounts';
|
2020-05-07 00:40:54 +01:00
|
|
|
import {
|
|
|
|
deleteStatus,
|
|
|
|
editStatus,
|
|
|
|
} from '../../actions/statuses';
|
2020-05-15 04:36:10 +01:00
|
|
|
import { quoteCompose } from '../../actions/compose'
|
2020-12-17 06:34:00 +00:00
|
|
|
import {
|
|
|
|
fetchBookmarkCollections,
|
|
|
|
updateBookmarkCollectionStatus,
|
|
|
|
} from '../../actions/bookmarks'
|
2020-05-07 00:40:54 +01:00
|
|
|
import {
|
|
|
|
fetchGroupRelationships,
|
|
|
|
createRemovedAccount,
|
|
|
|
groupRemoveStatus,
|
2020-09-10 21:07:01 +01:00
|
|
|
pinGroupStatus,
|
|
|
|
unpinGroupStatus,
|
2020-11-25 21:22:37 +00:00
|
|
|
isPinnedGroupStatus,
|
2020-05-07 00:40:54 +01:00
|
|
|
} from '../../actions/groups'
|
|
|
|
import { initReport } from '../../actions/reports'
|
|
|
|
import { openModal } from '../../actions/modal'
|
2020-10-30 04:38:55 +00:00
|
|
|
import {
|
|
|
|
closePopover,
|
|
|
|
openPopover,
|
|
|
|
} from '../../actions/popover'
|
2020-07-25 00:48:31 +01:00
|
|
|
import {
|
|
|
|
MODAL_PRO_UPGRADE,
|
2020-12-24 18:27:55 +00:00
|
|
|
POPOVER_SHARE,
|
2020-07-25 00:48:31 +01:00
|
|
|
} from '../../constants'
|
2020-03-25 03:08:43 +00:00
|
|
|
import PopoverLayout from './popover_layout'
|
2020-12-17 06:34:00 +00:00
|
|
|
import Button from '../button'
|
2020-03-25 03:08:43 +00:00
|
|
|
import List from '../list'
|
2020-12-17 06:34:00 +00:00
|
|
|
import Text from '../text'
|
2020-03-25 03:08:43 +00:00
|
|
|
|
2020-03-26 03:11:32 +00:00
|
|
|
class StatusOptionsPopover extends ImmutablePureComponent {
|
2020-05-01 06:50:27 +01:00
|
|
|
|
2020-05-15 04:17:31 +01:00
|
|
|
static contextTypes = {
|
|
|
|
router: PropTypes.object,
|
|
|
|
}
|
2020-04-22 06:00:11 +01:00
|
|
|
|
2020-12-17 06:34:00 +00:00
|
|
|
state = {
|
|
|
|
showingBookmarkCollections: false,
|
|
|
|
}
|
2020-04-22 06:00:11 +01:00
|
|
|
|
2020-05-07 00:40:54 +01:00
|
|
|
componentDidMount() {
|
2020-11-25 21:22:37 +00:00
|
|
|
const {
|
|
|
|
status,
|
|
|
|
statusId,
|
|
|
|
groupRelationships,
|
|
|
|
} = this.props
|
|
|
|
|
|
|
|
if (status.get('pinnable')) {
|
|
|
|
this.props.fetchIsPin(statusId)
|
|
|
|
}
|
|
|
|
this.props.fetchIsBookmark(statusId)
|
|
|
|
|
|
|
|
if (!!status.get('group')) {
|
|
|
|
this.props.fetchIsPinnedGroupStatus(status.getIn(['group', 'id'], null), statusId)
|
|
|
|
}
|
|
|
|
|
2020-05-07 00:40:54 +01:00
|
|
|
if (!this.props.groupRelationships && this.props.groupId) {
|
|
|
|
this.props.onFetchGroupRelationships(this.props.groupId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-22 06:00:11 +01:00
|
|
|
handleGroupRemoveAccount = () => {
|
2020-05-07 00:40:54 +01:00
|
|
|
const { status } = this.props
|
|
|
|
this.props.onGroupRemoveAccount(status.getIn(['group', 'id']), status.getIn(['account', 'id']))
|
2020-04-22 06:00:11 +01:00
|
|
|
}
|
2020-03-04 03:45:16 +00:00
|
|
|
|
2020-04-22 06:00:11 +01:00
|
|
|
handleGroupRemovePost = () => {
|
2020-05-07 00:40:54 +01:00
|
|
|
const { status } = this.props
|
2020-03-25 03:08:43 +00:00
|
|
|
|
2020-05-07 00:40:54 +01:00
|
|
|
this.props.onGroupRemoveStatus(status.getIn(['group', 'id']), status.get('id'))
|
2020-04-22 06:00:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
handleReport = () => {
|
2020-05-07 00:40:54 +01:00
|
|
|
this.props.onReport(this.props.status)
|
2020-04-22 06:00:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
handleBlockClick = () => {
|
2020-05-07 00:40:54 +01:00
|
|
|
this.props.onBlock(this.props.status)
|
2020-04-22 06:00:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
handleMuteClick = () => {
|
2020-05-07 00:40:54 +01:00
|
|
|
this.props.onMute(this.props.status.get('account'))
|
2020-04-22 06:00:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
handlePinClick = () => {
|
2020-05-07 00:40:54 +01:00
|
|
|
this.props.onPin(this.props.status)
|
2020-04-22 06:00:11 +01:00
|
|
|
}
|
|
|
|
|
2020-09-10 21:07:01 +01:00
|
|
|
handleGroupPinStatus = () => {
|
|
|
|
this.props.onPinGroupStatus(this.props.status)
|
|
|
|
}
|
|
|
|
|
2020-07-25 00:48:31 +01:00
|
|
|
handleBookmarkClick = () => {
|
2020-12-17 06:34:00 +00:00
|
|
|
// : todo : add to specific bookmark collection
|
2020-07-25 00:48:31 +01:00
|
|
|
if (this.props.isPro) {
|
|
|
|
this.props.onBookmark(this.props.status)
|
|
|
|
} else {
|
|
|
|
this.props.onOpenProUpgradeModal()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-17 06:34:00 +00:00
|
|
|
handleBookmarkChangeClick = () => {
|
|
|
|
if (!this.props.bookmarkCollectionsIsFetched) this.props.onFetchBookmarkCollections()
|
|
|
|
this.setState({ showingBookmarkCollections: true })
|
|
|
|
}
|
|
|
|
|
|
|
|
handleBookmarkChangeBackClick = () => {
|
|
|
|
this.setState({ showingBookmarkCollections: false })
|
|
|
|
}
|
|
|
|
|
|
|
|
handleBookmarkChangeSelectClick = (bookmarkCollectionId) => {
|
|
|
|
this.props.onUpdateBookmarkCollectionStatus(this.props.status.get('id'), bookmarkCollectionId)
|
|
|
|
}
|
|
|
|
|
2020-04-22 06:00:11 +01:00
|
|
|
handleDeleteClick = () => {
|
2020-05-07 00:40:54 +01:00
|
|
|
this.props.onDelete(this.props.status)
|
2020-04-22 06:00:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
handleEditClick = () => {
|
2020-05-07 00:40:54 +01:00
|
|
|
this.props.onEdit(this.props.status)
|
2020-04-22 06:00:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
handleRepostClick = (e) => {
|
2020-05-07 00:40:54 +01:00
|
|
|
this.props.onRepost(this.props.status, e)
|
2020-04-22 06:00:11 +01:00
|
|
|
}
|
|
|
|
|
2020-05-15 04:36:10 +01:00
|
|
|
handleQuoteClick = (e) => {
|
|
|
|
this.props.onQuote(this.props.status, this.context.router)
|
|
|
|
}
|
|
|
|
|
2020-10-30 04:38:55 +00:00
|
|
|
handleOnOpenSharePopover = () => {
|
|
|
|
this.props.onOpenSharePopover(this.props.innerRef, this.props.status)
|
2020-07-06 21:13:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
handleClosePopover = () => {
|
2020-05-27 06:13:46 +01:00
|
|
|
this.props.onClosePopover()
|
|
|
|
}
|
|
|
|
|
2020-05-01 06:50:27 +01:00
|
|
|
render() {
|
2020-04-22 06:00:11 +01:00
|
|
|
const {
|
2020-12-17 06:34:00 +00:00
|
|
|
isXS,
|
2020-04-22 06:00:11 +01:00
|
|
|
intl,
|
2020-12-17 06:34:00 +00:00
|
|
|
status,
|
2020-05-07 00:40:54 +01:00
|
|
|
groupRelationships,
|
2020-12-17 06:34:00 +00:00
|
|
|
bookmarkCollections,
|
2020-04-22 06:00:11 +01:00
|
|
|
} = this.props
|
2020-12-17 06:34:00 +00:00
|
|
|
const { showingBookmarkCollections } = this.state
|
2020-04-22 06:00:11 +01:00
|
|
|
|
2020-11-25 21:22:37 +00:00
|
|
|
if (!status) return <div />
|
|
|
|
|
2020-04-22 06:00:11 +01:00
|
|
|
const mutingConversation = status.get('muted')
|
|
|
|
const publicStatus = ['public', 'unlisted'].includes(status.get('visibility'))
|
2020-05-07 00:40:54 +01:00
|
|
|
const isReply = !!status.get('in_reply_to_id')
|
2020-09-03 00:06:38 +01:00
|
|
|
const withGroupAdmin = !!groupRelationships ? (groupRelationships.get('admin') || groupRelationships.get('moderator')) : false
|
2020-04-22 06:00:11 +01:00
|
|
|
|
2020-05-07 00:40:54 +01:00
|
|
|
let menu = []
|
2020-03-25 03:08:43 +00:00
|
|
|
|
2020-05-01 06:50:27 +01:00
|
|
|
if (me) {
|
2020-05-07 00:40:54 +01:00
|
|
|
if (isReply) {
|
|
|
|
menu.push({
|
|
|
|
icon: 'pencil',
|
|
|
|
hideArrow: true,
|
|
|
|
title: intl.formatMessage(messages.repostWithComment),
|
2020-05-15 04:36:10 +01:00
|
|
|
onClick: this.handleQuoteClick,
|
2020-05-07 00:40:54 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-07-25 00:48:31 +01:00
|
|
|
menu.push({
|
|
|
|
icon: 'bookmark',
|
2020-12-17 06:34:00 +00:00
|
|
|
hideArrow: status.get('bookmarked'),
|
2020-07-25 00:48:31 +01:00
|
|
|
title: intl.formatMessage(status.get('bookmarked') ? messages.unbookmark : messages.bookmark),
|
|
|
|
onClick: this.handleBookmarkClick,
|
|
|
|
})
|
2020-12-17 06:34:00 +00:00
|
|
|
|
|
|
|
if (status.get('bookmarked')) {
|
2020-12-22 17:11:22 +00:00
|
|
|
// : todo :
|
|
|
|
// menu.push({
|
|
|
|
// icon: 'bookmark',
|
|
|
|
// title: 'Update bookmark collection',
|
|
|
|
// onClick: this.handleBookmarkChangeClick,
|
|
|
|
// })
|
2020-12-17 06:34:00 +00:00
|
|
|
}
|
|
|
|
|
2020-05-07 00:40:54 +01:00
|
|
|
if (status.getIn(['account', 'id']) === me) {
|
|
|
|
if (publicStatus) {
|
2020-03-26 03:11:32 +00:00
|
|
|
menu.push({
|
2020-05-01 06:50:27 +01:00
|
|
|
icon: 'pin',
|
2020-04-22 06:00:11 +01:00
|
|
|
hideArrow: true,
|
2020-05-01 06:50:27 +01:00
|
|
|
title: intl.formatMessage(status.get('pinned') ? messages.unpin : messages.pin),
|
|
|
|
onClick: this.handlePinClick,
|
2020-03-26 03:11:32 +00:00
|
|
|
})
|
2020-05-07 00:40:54 +01:00
|
|
|
}
|
2020-07-25 00:48:31 +01:00
|
|
|
|
2020-04-22 06:00:11 +01:00
|
|
|
menu.push({
|
2020-05-01 06:50:27 +01:00
|
|
|
icon: 'trash',
|
|
|
|
hideArrow: true,
|
|
|
|
title: intl.formatMessage(messages.delete),
|
2020-05-07 00:40:54 +01:00
|
|
|
onClick: this.handleDeleteClick,
|
|
|
|
})
|
2020-04-22 06:00:11 +01:00
|
|
|
menu.push({
|
2020-05-01 06:50:27 +01:00
|
|
|
icon: 'pencil',
|
|
|
|
hideArrow: true,
|
2020-05-07 00:40:54 +01:00
|
|
|
title: intl.formatMessage(messages.edit),
|
|
|
|
onClick: this.handleEditClick,
|
|
|
|
})
|
|
|
|
} else {
|
2020-05-01 06:50:27 +01:00
|
|
|
menu.push({
|
|
|
|
icon: 'audio-mute',
|
|
|
|
hideArrow: true,
|
|
|
|
title: intl.formatMessage(messages.mute, { name: status.getIn(['account', 'username']) }),
|
2020-05-07 00:40:54 +01:00
|
|
|
onClick: this.handleMuteClick,
|
|
|
|
})
|
2020-05-01 06:50:27 +01:00
|
|
|
menu.push({
|
2020-05-07 00:40:54 +01:00
|
|
|
icon: 'block',
|
2020-05-01 06:50:27 +01:00
|
|
|
hideArrow: true,
|
|
|
|
title: intl.formatMessage(messages.block, { name: status.getIn(['account', 'username']) }),
|
2020-05-07 00:40:54 +01:00
|
|
|
onClick: this.handleBlockClick,
|
|
|
|
})
|
2020-05-01 06:50:27 +01:00
|
|
|
menu.push({
|
2020-05-07 00:40:54 +01:00
|
|
|
icon: 'warning',
|
2020-05-01 06:50:27 +01:00
|
|
|
hideArrow: true,
|
|
|
|
title: intl.formatMessage(messages.report, { name: status.getIn(['account', 'username']) }),
|
2020-05-07 00:40:54 +01:00
|
|
|
onClick: this.handleReport,
|
|
|
|
})
|
|
|
|
}
|
2020-05-01 06:50:27 +01:00
|
|
|
}
|
2020-03-26 03:11:32 +00:00
|
|
|
|
2021-01-19 05:38:37 +00:00
|
|
|
if (withGroupAdmin || (!!groupRelationships && isStaff)) {
|
2020-09-10 21:07:01 +01:00
|
|
|
menu.push(null)
|
|
|
|
menu.push({
|
|
|
|
icon: 'trash',
|
|
|
|
hideArrow: true,
|
|
|
|
title: intl.formatMessage(messages.group_remove_account),
|
|
|
|
onClick: this.handleGroupRemoveAccount,
|
|
|
|
})
|
|
|
|
menu.push({
|
|
|
|
icon: 'trash',
|
|
|
|
hideArrow: true,
|
|
|
|
title: intl.formatMessage(messages.group_remove_post),
|
|
|
|
onClick: this.handleGroupRemovePost,
|
|
|
|
})
|
|
|
|
menu.push(null)
|
|
|
|
menu.push({
|
|
|
|
icon: 'pin',
|
|
|
|
hideArrow: true,
|
|
|
|
title: intl.formatMessage(status.get('pinned_by_group') ? messages.groupUnpin : messages.groupPin),
|
|
|
|
onClick: this.handleGroupPinStatus,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-07-06 21:13:44 +01:00
|
|
|
menu.push(null)
|
2020-05-27 06:13:46 +01:00
|
|
|
menu.push({
|
2020-10-30 04:38:55 +00:00
|
|
|
icon: 'share',
|
2020-05-27 06:13:46 +01:00
|
|
|
hideArrow: true,
|
2020-10-30 04:38:55 +00:00
|
|
|
title: intl.formatMessage(messages.share),
|
|
|
|
onClick: this.handleOnOpenSharePopover,
|
2020-05-27 06:13:46 +01:00
|
|
|
})
|
2020-07-06 21:13:44 +01:00
|
|
|
|
|
|
|
if (isStaff) {
|
|
|
|
menu.push(null)
|
|
|
|
|
|
|
|
menu.push({
|
|
|
|
title: intl.formatMessage(messages.admin_account, { name: status.getIn(['account', 'username']) }),
|
2021-02-11 05:23:20 +00:00
|
|
|
href: `/admin/accounts/${status.getIn(['account', 'id'])}`,
|
|
|
|
openInNewTab: true,
|
2020-07-06 21:13:44 +01:00
|
|
|
})
|
|
|
|
menu.push({
|
|
|
|
title: intl.formatMessage(messages.admin_status),
|
2021-02-11 05:23:20 +00:00
|
|
|
href: `/admin/accounts/${status.getIn(['account', 'id'])}/account_statuses/${status.get('id')}`,
|
|
|
|
openInNewTab: true,
|
2020-07-06 21:13:44 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-12-17 06:34:00 +00:00
|
|
|
const popoverWidth = !isStaff ? 260 : 362
|
|
|
|
|
|
|
|
let bookmarkCollectionItems = !!bookmarkCollections ? bookmarkCollections.map((bookmarkCollection) => ({
|
|
|
|
hideArrow: true,
|
|
|
|
onClick: () => this.handleBookmarkChangeSelectClick(bookmarkCollection.get('id')),
|
|
|
|
title: bookmarkCollection.get('title'),
|
|
|
|
isActive: bookmarkCollection.get('id') === status.get('bookmark_collection_id'),
|
|
|
|
})) : []
|
|
|
|
bookmarkCollectionItems = bookmarkCollectionItems.unshift({
|
|
|
|
hideArrow: true,
|
|
|
|
onClick: () => this.handleBookmarkChangeSelectClick('saved'),
|
|
|
|
title: 'Saved',
|
|
|
|
isActive: !status.get('bookmark_collection_id'),
|
|
|
|
})
|
|
|
|
|
2020-02-24 21:56:07 +00:00
|
|
|
return (
|
2020-07-06 21:13:44 +01:00
|
|
|
<PopoverLayout
|
|
|
|
isXS={isXS}
|
|
|
|
onClose={this.handleClosePopover}
|
2020-12-17 06:34:00 +00:00
|
|
|
width={popoverWidth}
|
2020-07-06 21:13:44 +01:00
|
|
|
>
|
2020-12-17 06:34:00 +00:00
|
|
|
{
|
|
|
|
!showingBookmarkCollections &&
|
|
|
|
<List
|
|
|
|
scrollKey='profile_options'
|
|
|
|
items={menu}
|
|
|
|
size={isXS ? 'large' : 'small'}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
{
|
|
|
|
showingBookmarkCollections &&
|
|
|
|
<div className={[_s.d, _s.w100PC].join(' ')}>
|
|
|
|
<div className={[_s.d, _s.flexRow, _s.bgSecondary].join(' ')}>
|
|
|
|
<Button
|
|
|
|
isText
|
|
|
|
icon='back'
|
|
|
|
color='primary'
|
|
|
|
backgroundColor='none'
|
|
|
|
className={[_s.aiCenter, _s.jcCenter, _s.pl15, _s.pr5].join(' ')}
|
|
|
|
onClick={this.handleBookmarkChangeBackClick}
|
|
|
|
/>
|
|
|
|
<Text className={[_s.d, _s.pl5, _s.py10].join(' ')}>
|
|
|
|
Select bookmark collection:
|
|
|
|
</Text>
|
|
|
|
</div>
|
|
|
|
<div className={[_s.d, _s.w100PC, _s.overflowYScroll, _s.maxH340PX].join(' ')}>
|
|
|
|
<List
|
|
|
|
scrollKey='status_options_bookmark_collections'
|
|
|
|
showLoading={bookmarkCollectionItems.length === 0}
|
|
|
|
emptyMessage="You have no bookmark collections yet."
|
|
|
|
items={bookmarkCollectionItems}
|
|
|
|
size={isXS ? 'large' : 'small'}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
}
|
2020-03-25 03:08:43 +00:00
|
|
|
</PopoverLayout>
|
2020-02-24 21:56:07 +00:00
|
|
|
)
|
|
|
|
}
|
2020-05-01 06:50:27 +01:00
|
|
|
|
2020-08-19 01:22:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
delete: { id: 'status.delete', defaultMessage: 'Delete' },
|
|
|
|
edit: { id: 'status.edit', defaultMessage: 'Edit' },
|
|
|
|
mute: { id: 'account.mute', defaultMessage: 'Mute @{name}' },
|
|
|
|
block: { id: 'account.block', defaultMessage: 'Block @{name}' },
|
|
|
|
reply: { id: 'status.reply', defaultMessage: 'Reply' },
|
|
|
|
more: { id: 'status.more', defaultMessage: 'More' },
|
|
|
|
share: { id: 'status.share', defaultMessage: 'Share' },
|
|
|
|
replyAll: { id: 'status.replyAll', defaultMessage: 'Reply to thread' },
|
|
|
|
repost: { id: 'repost', defaultMessage: 'Repost' },
|
|
|
|
quote: { id: 'status.quote', defaultMessage: 'Quote' },
|
|
|
|
repost_private: { id: 'status.repost', defaultMessage: 'Repost' },
|
|
|
|
cancel_repost_private: { id: 'status.cancel_repost_private', defaultMessage: 'Remove Repost' },
|
|
|
|
cannot_repost: { id: 'status.cannot_repost', defaultMessage: 'This post cannot be reposted' },
|
|
|
|
cannot_quote: { id: 'status.cannot_quote', defaultMessage: 'This post cannot be quoted' },
|
|
|
|
like: { id: 'status.like', defaultMessage: 'Like' },
|
|
|
|
report: { id: 'status.report', defaultMessage: 'Report @{name}' },
|
|
|
|
pin: { id: 'status.pin', defaultMessage: 'Pin on profile' },
|
|
|
|
unpin: { id: 'status.unpin', defaultMessage: 'Unpin from profile' },
|
2020-09-10 21:07:01 +01:00
|
|
|
groupPin: { id: 'status.group_pin', defaultMessage: 'Pin in group' },
|
|
|
|
groupUnpin: { id: 'status.group_unpin', defaultMessage: 'Unpin from group' },
|
2020-08-19 01:22:15 +01:00
|
|
|
bookmark: { id: 'status.bookmark', defaultMessage: 'Bookmark status' },
|
|
|
|
unbookmark: { id: 'status.unbookmark', defaultMessage: 'Remove bookmark' },
|
|
|
|
admin_account: { id: 'status.admin_account', defaultMessage: 'Open moderation interface for @{name}' },
|
|
|
|
admin_status: { id: 'status.admin_status', defaultMessage: 'Open this status in the moderation interface' },
|
|
|
|
group_remove_account: { id: 'status.remove_account_from_group', defaultMessage: 'Remove account from group' },
|
|
|
|
group_remove_post: { id: 'status.remove_post_from_group', defaultMessage: 'Remove status from group' },
|
|
|
|
repostWithComment: { id: 'repost_with_comment', defaultMessage: 'Repost with comment' },
|
2020-10-30 04:38:55 +00:00
|
|
|
share: { id: 'status.share_gab', defaultMessage: 'Share gab' },
|
2020-08-19 01:22:15 +01:00
|
|
|
})
|
|
|
|
|
2020-11-25 21:22:37 +00:00
|
|
|
const mapStateToProps = (state, { statusId }) => {
|
2020-08-19 01:22:15 +01:00
|
|
|
if (!me) return null
|
2020-11-25 21:22:37 +00:00
|
|
|
|
|
|
|
const status = statusId ? makeGetStatus()(state, { id: statusId }) : undefined
|
2020-08-19 01:22:15 +01:00
|
|
|
const groupId = status ? status.getIn(['group', 'id']) : undefined
|
|
|
|
const groupRelationships = state.getIn(['group_relationships', groupId])
|
|
|
|
|
|
|
|
return {
|
2020-11-25 21:22:37 +00:00
|
|
|
status,
|
2020-08-19 01:22:15 +01:00
|
|
|
groupId,
|
|
|
|
groupRelationships,
|
|
|
|
isPro: state.getIn(['accounts', me, 'is_pro']),
|
2020-12-17 06:34:00 +00:00
|
|
|
bookmarkCollectionsIsFetched: state.getIn(['bookmark_collections', 'isFetched']),
|
|
|
|
bookmarkCollections: state.getIn(['bookmark_collections', 'items']),
|
2020-08-19 01:22:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
2020-11-25 21:22:37 +00:00
|
|
|
fetchIsPin(statusId) {
|
|
|
|
dispatch(isPin(statusId))
|
|
|
|
},
|
|
|
|
|
|
|
|
fetchIsBookmark(statusId) {
|
|
|
|
dispatch(isBookmark(statusId))
|
|
|
|
},
|
|
|
|
|
|
|
|
fetchIsPinnedGroupStatus(groupId, statusId) {
|
|
|
|
dispatch(isPinnedGroupStatus(groupId, statusId))
|
|
|
|
},
|
|
|
|
|
2020-08-19 01:22:15 +01:00
|
|
|
onPin(status) {
|
|
|
|
dispatch(closePopover())
|
|
|
|
|
|
|
|
if (status.get('pinned')) {
|
|
|
|
dispatch(unpin(status))
|
|
|
|
} else {
|
|
|
|
dispatch(pin(status))
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onBookmark(status) {
|
|
|
|
dispatch(closePopover())
|
|
|
|
|
|
|
|
if (status.get('bookmarked')) {
|
|
|
|
dispatch(unbookmark(status))
|
|
|
|
} else {
|
|
|
|
dispatch(bookmark(status))
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onQuote(status, router) {
|
|
|
|
dispatch(closePopover())
|
|
|
|
|
|
|
|
dispatch((_, getState) => {
|
|
|
|
const state = getState()
|
|
|
|
if (state.getIn(['compose', 'text']).trim().length !== 0) {
|
|
|
|
dispatch(openModal(MODAL_CONFIRM, {
|
|
|
|
message: intl.formatMessage(messages.quoteMessage),
|
|
|
|
confirm: intl.formatMessage(messages.quoteConfirm),
|
|
|
|
onConfirm: () => dispatch(quoteCompose(status, router)),
|
|
|
|
}))
|
|
|
|
} else {
|
|
|
|
dispatch(quoteCompose(status, router))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
onRepost(status) {
|
|
|
|
dispatch(closePopover())
|
|
|
|
const alreadyReposted = status.get('reblogged')
|
|
|
|
|
|
|
|
if (boostModal && !alreadyReposted) {
|
|
|
|
dispatch(openModal(MODAL_BOOST, {
|
|
|
|
status,
|
|
|
|
onRepost: () => dispatch(repost(status)),
|
|
|
|
}))
|
|
|
|
} else {
|
|
|
|
if (alreadyReposted) {
|
|
|
|
dispatch(unrepost(status))
|
|
|
|
} else {
|
|
|
|
dispatch(repost(status))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onDelete(status, history) {
|
|
|
|
dispatch(closePopover())
|
|
|
|
|
|
|
|
if (!deleteModal) {
|
|
|
|
dispatch(deleteStatus(status.get('id'), history))
|
|
|
|
} else {
|
|
|
|
dispatch(openModal('CONFIRM', {
|
|
|
|
message: <FormattedMessage id='confirmations.delete.message' defaultMessage='Are you sure you want to delete this status?' />,
|
|
|
|
confirm: <FormattedMessage id='confirmations.delete.confirm' defaultMessage='Delete' />,
|
|
|
|
onConfirm: () => dispatch(deleteStatus(status.get('id'), history)),
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onEdit(status) {
|
|
|
|
dispatch(closePopover())
|
|
|
|
dispatch(editStatus(status))
|
|
|
|
},
|
|
|
|
|
|
|
|
onBlock(status) {
|
|
|
|
dispatch(closePopover())
|
|
|
|
const account = status.get('account')
|
|
|
|
dispatch(openModal('BLOCK_ACCOUNT', {
|
|
|
|
accountId: account.get('id'),
|
|
|
|
}))
|
|
|
|
},
|
2020-12-21 23:30:46 +00:00
|
|
|
onMute(account) {
|
|
|
|
dispatch(closePopover())
|
|
|
|
if (account.getIn(['relationship', 'muting'])) {
|
|
|
|
dispatch(unmuteAccount(account.get('id')));
|
|
|
|
} else {
|
|
|
|
dispatch(openModal('MUTE', {
|
|
|
|
accountId: account.get('id'),
|
|
|
|
}))
|
|
|
|
}
|
|
|
|
},
|
2020-08-19 01:22:15 +01:00
|
|
|
onReport(status) {
|
|
|
|
dispatch(closePopover())
|
|
|
|
dispatch(initReport(status.get('account'), status))
|
|
|
|
},
|
|
|
|
|
|
|
|
onGroupRemoveAccount(groupId, accountId) {
|
|
|
|
dispatch(closePopover())
|
|
|
|
dispatch(createRemovedAccount(groupId, accountId))
|
|
|
|
},
|
|
|
|
|
|
|
|
onGroupRemoveStatus(groupId, statusId) {
|
|
|
|
dispatch(closePopover())
|
|
|
|
dispatch(groupRemoveStatus(groupId, statusId))
|
|
|
|
},
|
|
|
|
|
|
|
|
onFetchGroupRelationships(groupId) {
|
|
|
|
dispatch(fetchGroupRelationships([groupId]))
|
|
|
|
},
|
|
|
|
|
2020-10-30 04:38:55 +00:00
|
|
|
onOpenSharePopover(targetRef, status) {
|
2020-08-19 01:22:15 +01:00
|
|
|
dispatch(closePopover())
|
2020-12-24 18:27:55 +00:00
|
|
|
dispatch(openPopover(POPOVER_SHARE, {
|
2020-10-30 04:38:55 +00:00
|
|
|
targetRef,
|
|
|
|
status,
|
|
|
|
position: 'top',
|
2020-08-19 01:22:15 +01:00
|
|
|
}))
|
|
|
|
},
|
|
|
|
|
|
|
|
onOpenProUpgradeModal() {
|
|
|
|
dispatch(closePopover())
|
|
|
|
dispatch(openModal(MODAL_PRO_UPGRADE))
|
|
|
|
},
|
2020-09-10 21:07:01 +01:00
|
|
|
onPinGroupStatus(status) {
|
|
|
|
dispatch(closePopover())
|
|
|
|
|
|
|
|
if (status.get('pinned_by_group')) {
|
|
|
|
dispatch(unpinGroupStatus(status.getIn(['group', 'id']), status.get('id')))
|
|
|
|
} else {
|
|
|
|
dispatch(pinGroupStatus(status.getIn(['group', 'id']), status.get('id')))
|
|
|
|
}
|
|
|
|
},
|
2020-12-17 06:34:00 +00:00
|
|
|
onFetchBookmarkCollections() {
|
|
|
|
dispatch(fetchBookmarkCollections())
|
|
|
|
},
|
|
|
|
onUpdateBookmarkCollectionStatus(statusId, bookmarkCollectionId) {
|
|
|
|
dispatch(updateBookmarkCollectionStatus(statusId, bookmarkCollectionId))
|
|
|
|
dispatch(closePopover())
|
|
|
|
},
|
2020-08-19 01:22:15 +01:00
|
|
|
onClosePopover: () => dispatch(closePopover()),
|
|
|
|
})
|
|
|
|
|
|
|
|
StatusOptionsPopover.propTypes = {
|
2020-11-25 21:22:37 +00:00
|
|
|
status: ImmutablePropTypes.map,
|
|
|
|
statusId: PropTypes.string.isRequired,
|
2020-08-19 01:22:15 +01:00
|
|
|
groupRelationships: ImmutablePropTypes.map,
|
|
|
|
groupId: PropTypes.string,
|
|
|
|
onQuote: PropTypes.func.isRequired,
|
|
|
|
onRepost: PropTypes.func.isRequired,
|
|
|
|
onDelete: PropTypes.func.isRequired,
|
|
|
|
onMute: PropTypes.func.isRequired,
|
|
|
|
onBlock: PropTypes.func.isRequired,
|
|
|
|
onReport: PropTypes.func.isRequired,
|
|
|
|
onPin: PropTypes.func.isRequired,
|
|
|
|
intl: PropTypes.object.isRequired,
|
|
|
|
onFetchGroupRelationships: PropTypes.func.isRequired,
|
|
|
|
onOpenProUpgradeModal: PropTypes.func.isRequired,
|
|
|
|
onClosePopover: PropTypes.func.isRequired,
|
2020-11-25 21:22:37 +00:00
|
|
|
fetchIsPinnedGroupStatus: PropTypes.func.isRequired,
|
|
|
|
fetchIsBookmark: PropTypes.func.isRequired,
|
|
|
|
fetchIsPin: PropTypes.func.isRequired,
|
2020-12-17 06:34:00 +00:00
|
|
|
onFetchBookmarkCollections: PropTypes.func.isRequired,
|
|
|
|
onUpdateBookmarkCollectionStatus: PropTypes.func.isRequired,
|
2020-08-19 01:22:15 +01:00
|
|
|
isXS: PropTypes.bool,
|
|
|
|
isPro: PropTypes.bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(StatusOptionsPopover))
|