You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
251 lines
7.2 KiB
251 lines
7.2 KiB
5 years ago
|
import React from 'react';
|
||
8 years ago
|
import { connect } from 'react-redux';
|
||
|
import Status from '../components/status';
|
||
4 years ago
|
import { makeGetStatus, makeGetPictureInPicture } from '../selectors';
|
||
8 years ago
|
import {
|
||
|
replyCompose,
|
||
8 years ago
|
mentionCompose,
|
||
7 years ago
|
directCompose,
|
||
8 years ago
|
} from '../actions/compose';
|
||
8 years ago
|
import {
|
||
|
reblog,
|
||
|
favourite,
|
||
5 years ago
|
bookmark,
|
||
8 years ago
|
unreblog,
|
||
8 years ago
|
unfavourite,
|
||
5 years ago
|
unbookmark,
|
||
7 years ago
|
pin,
|
||
|
unpin,
|
||
8 years ago
|
} from '../actions/interactions';
|
||
7 years ago
|
import {
|
||
|
muteStatus,
|
||
|
unmuteStatus,
|
||
|
deleteStatus,
|
||
|
hideStatus,
|
||
|
revealStatus,
|
||
5 years ago
|
toggleStatusCollapse,
|
||
3 years ago
|
editStatus,
|
||
2 years ago
|
translateStatus,
|
||
|
undoStatusTranslation,
|
||
7 years ago
|
} from '../actions/statuses';
|
||
5 years ago
|
import {
|
||
|
unmuteAccount,
|
||
|
unblockAccount,
|
||
|
} from '../actions/accounts';
|
||
|
import {
|
||
|
blockDomain,
|
||
|
unblockDomain,
|
||
|
} from '../actions/domain_blocks';
|
||
2 years ago
|
import {
|
||
|
initAddFilter,
|
||
|
} from '../actions/filters';
|
||
7 years ago
|
import { initMuteModal } from '../actions/mutes';
|
||
5 years ago
|
import { initBlockModal } from '../actions/blocks';
|
||
4 years ago
|
import { initBoostModal } from '../actions/boosts';
|
||
8 years ago
|
import { initReport } from '../actions/reports';
|
||
8 years ago
|
import { openModal } from '../actions/modal';
|
||
4 years ago
|
import { deployPictureInPicture } from '../actions/picture_in_picture';
|
||
5 years ago
|
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
|
||
7 years ago
|
import { boostModal, deleteModal } from '../initial_state';
|
||
7 years ago
|
import { showAlertForError } from '../actions/alerts';
|
||
8 years ago
|
|
||
|
const messages = defineMessages({
|
||
|
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
|
||
|
deleteMessage: { id: 'confirmations.delete.message', defaultMessage: 'Are you sure you want to delete this status?' },
|
||
7 years ago
|
redraftConfirm: { id: 'confirmations.redraft.confirm', defaultMessage: 'Delete & redraft' },
|
||
6 years ago
|
redraftMessage: { id: 'confirmations.redraft.message', defaultMessage: 'Are you sure you want to delete this status and re-draft it? Favourites and boosts will be lost, and replies to the original post will be orphaned.' },
|
||
6 years ago
|
replyConfirm: { id: 'confirmations.reply.confirm', defaultMessage: 'Reply' },
|
||
|
replyMessage: { id: 'confirmations.reply.message', defaultMessage: 'Replying now will overwrite the message you are currently composing. Are you sure you want to proceed?' },
|
||
5 years ago
|
blockDomainConfirm: { id: 'confirmations.domain_block.confirm', defaultMessage: 'Hide entire domain' },
|
||
8 years ago
|
});
|
||
8 years ago
|
|
||
8 years ago
|
const makeMapStateToProps = () => {
|
||
|
const getStatus = makeGetStatus();
|
||
4 years ago
|
const getPictureInPicture = makeGetPictureInPicture();
|
||
8 years ago
|
|
||
8 years ago
|
const mapStateToProps = (state, props) => ({
|
||
6 years ago
|
status: getStatus(state, props),
|
||
4 years ago
|
pictureInPicture: getPictureInPicture(state, props),
|
||
8 years ago
|
});
|
||
|
|
||
|
return mapStateToProps;
|
||
|
};
|
||
|
|
||
2 years ago
|
const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
|
||
8 years ago
|
|
||
8 years ago
|
onReply (status, router) {
|
||
6 years ago
|
dispatch((_, getState) => {
|
||
|
let state = getState();
|
||
5 years ago
|
|
||
6 years ago
|
if (state.getIn(['compose', 'text']).trim().length !== 0) {
|
||
|
dispatch(openModal('CONFIRM', {
|
||
|
message: intl.formatMessage(messages.replyMessage),
|
||
|
confirm: intl.formatMessage(messages.replyConfirm),
|
||
|
onConfirm: () => dispatch(replyCompose(status, router)),
|
||
|
}));
|
||
|
} else {
|
||
|
dispatch(replyCompose(status, router));
|
||
|
}
|
||
|
});
|
||
8 years ago
|
},
|
||
|
|
||
4 years ago
|
onModalReblog (status, privacy) {
|
||
6 years ago
|
if (status.get('reblogged')) {
|
||
|
dispatch(unreblog(status));
|
||
|
} else {
|
||
4 years ago
|
dispatch(reblog(status, privacy));
|
||
6 years ago
|
}
|
||
8 years ago
|
},
|
||
|
|
||
8 years ago
|
onReblog (status, e) {
|
||
5 years ago
|
if ((e && e.shiftKey) || !boostModal) {
|
||
6 years ago
|
this.onModalReblog(status);
|
||
8 years ago
|
} else {
|
||
4 years ago
|
dispatch(initBoostModal({ status, onReblog: this.onModalReblog }));
|
||
8 years ago
|
}
|
||
|
},
|
||
|
|
||
|
onFavourite (status) {
|
||
|
if (status.get('favourited')) {
|
||
|
dispatch(unfavourite(status));
|
||
|
} else {
|
||
|
dispatch(favourite(status));
|
||
|
}
|
||
|
},
|
||
|
|
||
5 years ago
|
onBookmark (status) {
|
||
|
if (status.get('bookmarked')) {
|
||
|
dispatch(unbookmark(status));
|
||
|
} else {
|
||
|
dispatch(bookmark(status));
|
||
|
}
|
||
|
},
|
||
|
|
||
7 years ago
|
onPin (status) {
|
||
|
if (status.get('pinned')) {
|
||
|
dispatch(unpin(status));
|
||
|
} else {
|
||
|
dispatch(pin(status));
|
||
|
}
|
||
|
},
|
||
|
|
||
7 years ago
|
onEmbed (status) {
|
||
7 years ago
|
dispatch(openModal('EMBED', {
|
||
|
url: status.get('url'),
|
||
|
onError: error => dispatch(showAlertForError(error)),
|
||
|
}));
|
||
7 years ago
|
},
|
||
|
|
||
6 years ago
|
onDelete (status, history, withRedraft = false) {
|
||
7 years ago
|
if (!deleteModal) {
|
||
6 years ago
|
dispatch(deleteStatus(status.get('id'), history, withRedraft));
|
||
8 years ago
|
} else {
|
||
|
dispatch(openModal('CONFIRM', {
|
||
7 years ago
|
message: intl.formatMessage(withRedraft ? messages.redraftMessage : messages.deleteMessage),
|
||
|
confirm: intl.formatMessage(withRedraft ? messages.redraftConfirm : messages.deleteConfirm),
|
||
6 years ago
|
onConfirm: () => dispatch(deleteStatus(status.get('id'), history, withRedraft)),
|
||
8 years ago
|
}));
|
||
|
}
|
||
8 years ago
|
},
|
||
|
|
||
3 years ago
|
onEdit (status, history) {
|
||
|
dispatch(editStatus(status.get('id'), history));
|
||
|
},
|
||
|
|
||
2 years ago
|
onTranslate (status) {
|
||
|
if (status.get('translation')) {
|
||
|
dispatch(undoStatusTranslation(status.get('id')));
|
||
|
} else {
|
||
|
dispatch(translateStatus(status.get('id')));
|
||
|
}
|
||
|
},
|
||
|
|
||
7 years ago
|
onDirect (account, router) {
|
||
|
dispatch(directCompose(account, router));
|
||
|
},
|
||
|
|
||
8 years ago
|
onMention (account, router) {
|
||
8 years ago
|
dispatch(mentionCompose(account, router));
|
||
8 years ago
|
},
|
||
|
|
||
4 years ago
|
onOpenMedia (statusId, media, index) {
|
||
|
dispatch(openModal('MEDIA', { statusId, media, index }));
|
||
8 years ago
|
},
|
||
|
|
||
4 years ago
|
onOpenVideo (statusId, media, options) {
|
||
|
dispatch(openModal('VIDEO', { statusId, media, options }));
|
||
8 years ago
|
},
|
||
|
|
||
6 years ago
|
onBlock (status) {
|
||
|
const account = status.get('account');
|
||
5 years ago
|
dispatch(initBlockModal(account));
|
||
8 years ago
|
},
|
||
|
|
||
5 years ago
|
onUnblock (account) {
|
||
|
dispatch(unblockAccount(account.get('id')));
|
||
|
},
|
||
|
|
||
8 years ago
|
onReport (status) {
|
||
|
dispatch(initReport(status.get('account'), status));
|
||
8 years ago
|
},
|
||
|
|
||
2 years ago
|
onAddFilter (status) {
|
||
|
dispatch(initAddFilter(status, { contextType }));
|
||
|
},
|
||
|
|
||
8 years ago
|
onMute (account) {
|
||
7 years ago
|
dispatch(initMuteModal(account));
|
||
8 years ago
|
},
|
||
8 years ago
|
|
||
5 years ago
|
onUnmute (account) {
|
||
|
dispatch(unmuteAccount(account.get('id')));
|
||
|
},
|
||
|
|
||
8 years ago
|
onMuteConversation (status) {
|
||
|
if (status.get('muted')) {
|
||
|
dispatch(unmuteStatus(status.get('id')));
|
||
|
} else {
|
||
|
dispatch(muteStatus(status.get('id')));
|
||
|
}
|
||
|
},
|
||
|
|
||
7 years ago
|
onToggleHidden (status) {
|
||
|
if (status.get('hidden')) {
|
||
|
dispatch(revealStatus(status.get('id')));
|
||
|
} else {
|
||
|
dispatch(hideStatus(status.get('id')));
|
||
|
}
|
||
|
},
|
||
|
|
||
5 years ago
|
onToggleCollapsed (status, isCollapsed) {
|
||
|
dispatch(toggleStatusCollapse(status.get('id'), isCollapsed));
|
||
|
},
|
||
|
|
||
5 years ago
|
onBlockDomain (domain) {
|
||
|
dispatch(openModal('CONFIRM', {
|
||
|
message: <FormattedMessage id='confirmations.domain_block.message' defaultMessage='Are you really, really sure you want to block the entire {domain}? In most cases a few targeted blocks or mutes are sufficient and preferable. You will not see content from that domain in any public timelines or your notifications. Your followers from that domain will be removed.' values={{ domain: <strong>{domain}</strong> }} />,
|
||
|
confirm: intl.formatMessage(messages.blockDomainConfirm),
|
||
|
onConfirm: () => dispatch(blockDomain(domain)),
|
||
|
}));
|
||
|
},
|
||
|
|
||
|
onUnblockDomain (domain) {
|
||
|
dispatch(unblockDomain(domain));
|
||
|
},
|
||
|
|
||
4 years ago
|
deployPictureInPicture (status, type, mediaProps) {
|
||
|
dispatch(deployPictureInPicture(status.get('id'), status.getIn(['account', 'id']), type, mediaProps));
|
||
|
},
|
||
|
|
||
2 years ago
|
onInteractionModal (type, status) {
|
||
|
dispatch(openModal('INTERACTION', {
|
||
|
type,
|
||
|
accountId: status.getIn(['account', 'id']),
|
||
|
url: status.get('url'),
|
||
|
}));
|
||
|
},
|
||
|
|
||
8 years ago
|
});
|
||
|
|
||
8 years ago
|
export default injectIntl(connect(makeMapStateToProps, mapDispatchToProps)(Status));
|