[Glitch] Remove routerHistory parameters from composer actions

Port e768b23aa9 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Claire 2024-07-19 17:26:44 +02:00
parent 9f05a06dee
commit 95984b729a
18 changed files with 94 additions and 104 deletions

View File

@ -4,6 +4,7 @@ import axios from 'axios';
import { throttle } from 'lodash'; import { throttle } from 'lodash';
import api from 'flavours/glitch/api'; import api from 'flavours/glitch/api';
import { browserHistory } from 'flavours/glitch/components/router';
import { search as emojiSearch } from 'flavours/glitch/features/emoji/emoji_mart_search_light'; import { search as emojiSearch } from 'flavours/glitch/features/emoji/emoji_mart_search_light';
import { tagHistory } from 'flavours/glitch/settings'; import { tagHistory } from 'flavours/glitch/settings';
import { recoverHashtags } from 'flavours/glitch/utils/hashtag'; import { recoverHashtags } from 'flavours/glitch/utils/hashtag';
@ -94,9 +95,9 @@ const messages = defineMessages({
saved: { id: 'compose.saved.body', defaultMessage: 'Post saved.' }, saved: { id: 'compose.saved.body', defaultMessage: 'Post saved.' },
}); });
export const ensureComposeIsVisible = (getState, routerHistory) => { export const ensureComposeIsVisible = (getState) => {
if (!getState().getIn(['compose', 'mounted'])) { if (!getState().getIn(['compose', 'mounted'])) {
routerHistory.push('/publish'); browserHistory.push('/publish');
} }
}; };
@ -117,7 +118,7 @@ export function changeCompose(text) {
}; };
} }
export function replyCompose(status, routerHistory) { export function replyCompose(status) {
return (dispatch, getState) => { return (dispatch, getState) => {
const prependCWRe = getState().getIn(['local_settings', 'prepend_cw_re']); const prependCWRe = getState().getIn(['local_settings', 'prepend_cw_re']);
dispatch({ dispatch({
@ -126,7 +127,7 @@ export function replyCompose(status, routerHistory) {
prependCWRe: prependCWRe, prependCWRe: prependCWRe,
}); });
ensureComposeIsVisible(getState, routerHistory); ensureComposeIsVisible(getState);
}; };
} }
@ -142,38 +143,38 @@ export function resetCompose() {
}; };
} }
export const focusCompose = (routerHistory, defaultText) => (dispatch, getState) => { export const focusCompose = (defaultText) => (dispatch, getState) => {
dispatch({ dispatch({
type: COMPOSE_FOCUS, type: COMPOSE_FOCUS,
defaultText, defaultText,
}); });
ensureComposeIsVisible(getState, routerHistory); ensureComposeIsVisible(getState);
}; };
export function mentionCompose(account, routerHistory) { export function mentionCompose(account) {
return (dispatch, getState) => { return (dispatch, getState) => {
dispatch({ dispatch({
type: COMPOSE_MENTION, type: COMPOSE_MENTION,
account: account, account: account,
}); });
ensureComposeIsVisible(getState, routerHistory); ensureComposeIsVisible(getState);
}; };
} }
export function directCompose(account, routerHistory) { export function directCompose(account) {
return (dispatch, getState) => { return (dispatch, getState) => {
dispatch({ dispatch({
type: COMPOSE_DIRECT, type: COMPOSE_DIRECT,
account: account, account: account,
}); });
ensureComposeIsVisible(getState, routerHistory); ensureComposeIsVisible(getState);
}; };
} }
export function submitCompose(routerHistory, overridePrivacy = null) { export function submitCompose(overridePrivacy = null) {
return function (dispatch, getState) { return function (dispatch, getState) {
let status = getState().getIn(['compose', 'text'], ''); let status = getState().getIn(['compose', 'text'], '');
const media = getState().getIn(['compose', 'media_attachments']); const media = getState().getIn(['compose', 'media_attachments']);
@ -230,11 +231,10 @@ export function submitCompose(routerHistory, overridePrivacy = null) {
'Idempotency-Key': getState().getIn(['compose', 'idempotencyKey']), 'Idempotency-Key': getState().getIn(['compose', 'idempotencyKey']),
}, },
}).then(function (response) { }).then(function (response) {
if (routerHistory if ((browserHistory.location.pathname === '/publish' || browserHistory.location.pathname === '/statuses/new')
&& (routerHistory.location.pathname === '/publish' || routerHistory.location.pathname === '/statuses/new')
&& window.history.state && window.history.state
&& !getState().getIn(['compose', 'advanced_options', 'threaded_mode'])) { && !getState().getIn(['compose', 'advanced_options', 'threaded_mode'])) {
routerHistory.goBack(); browserHistory.goBack();
} }
dispatch(insertIntoTagHistory(response.data.tags, status)); dispatch(insertIntoTagHistory(response.data.tags, status));
@ -272,7 +272,7 @@ export function submitCompose(routerHistory, overridePrivacy = null) {
message: statusId === null ? messages.published : messages.saved, message: statusId === null ? messages.published : messages.saved,
action: messages.open, action: messages.open,
dismissAfter: 10000, dismissAfter: 10000,
onClick: () => routerHistory.push(`/@${response.data.account.username}/${response.data.id}`), onClick: () => browserHistory.push(`/@${response.data.account.username}/${response.data.id}`),
})); }));
} }
}).catch(function (error) { }).catch(function (error) {

View File

@ -94,7 +94,7 @@ export function redraft(status, raw_text, content_type) {
}; };
} }
export const editStatus = (id, routerHistory) => (dispatch, getState) => { export const editStatus = (id) => (dispatch, getState) => {
let status = getState().getIn(['statuses', id]); let status = getState().getIn(['statuses', id]);
if (status.get('poll')) { if (status.get('poll')) {
@ -105,7 +105,7 @@ export const editStatus = (id, routerHistory) => (dispatch, getState) => {
api().get(`/api/v1/statuses/${id}/source`).then(response => { api().get(`/api/v1/statuses/${id}/source`).then(response => {
dispatch(fetchStatusSourceSuccess()); dispatch(fetchStatusSourceSuccess());
ensureComposeIsVisible(getState, routerHistory); ensureComposeIsVisible(getState);
dispatch(setComposeToStatus(status, response.data.text, response.data.spoiler_text, response.data.content_type)); dispatch(setComposeToStatus(status, response.data.text, response.data.spoiler_text, response.data.content_type));
}).catch(error => { }).catch(error => {
dispatch(fetchStatusSourceFail(error)); dispatch(fetchStatusSourceFail(error));
@ -125,7 +125,7 @@ export const fetchStatusSourceFail = error => ({
error, error,
}); });
export function deleteStatus(id, routerHistory, withRedraft = false) { export function deleteStatus(id, withRedraft = false) {
return (dispatch, getState) => { return (dispatch, getState) => {
let status = getState().getIn(['statuses', id]); let status = getState().getIn(['statuses', id]);
@ -142,7 +142,7 @@ export function deleteStatus(id, routerHistory, withRedraft = false) {
if (withRedraft) { if (withRedraft) {
dispatch(redraft(status, response.data.text, response.data.content_type)); dispatch(redraft(status, response.data.text, response.data.content_type));
ensureComposeIsVisible(getState, routerHistory); ensureComposeIsVisible(getState);
} }
}).catch(error => { }).catch(error => {
dispatch(deleteStatusFail(id, error)); dispatch(deleteStatusFail(id, error));

View File

@ -22,7 +22,7 @@ type LocationState = MastodonLocationState | null | undefined;
type HistoryPath = Path | LocationDescriptor<LocationState>; type HistoryPath = Path | LocationDescriptor<LocationState>;
const browserHistory = createBrowserHistory<LocationState>(); export const browserHistory = createBrowserHistory<LocationState>();
const originalPush = browserHistory.push.bind(browserHistory); const originalPush = browserHistory.push.bind(browserHistory);
const originalReplace = browserHistory.replace.bind(browserHistory); const originalReplace = browserHistory.replace.bind(browserHistory);

View File

@ -442,7 +442,7 @@ class Status extends ImmutablePureComponent {
handleHotkeyReply = e => { handleHotkeyReply = e => {
e.preventDefault(); e.preventDefault();
this.props.onReply(this.props.status, this.props.history); this.props.onReply(this.props.status);
}; };
handleHotkeyFavourite = (e) => { handleHotkeyFavourite = (e) => {
@ -459,7 +459,7 @@ class Status extends ImmutablePureComponent {
handleHotkeyMention = e => { handleHotkeyMention = e => {
e.preventDefault(); e.preventDefault();
this.props.onMention(this.props.status.get('account'), this.props.history); this.props.onMention(this.props.status.get('account'));
}; };
handleHotkeyOpen = () => { handleHotkeyOpen = () => {

View File

@ -108,7 +108,7 @@ class StatusActionBar extends ImmutablePureComponent {
const { signedIn } = this.props.identity; const { signedIn } = this.props.identity;
if (signedIn) { if (signedIn) {
this.props.onReply(this.props.status, this.props.history); this.props.onReply(this.props.status);
} else { } else {
this.props.onInteractionModal('reply', this.props.status); this.props.onInteractionModal('reply', this.props.status);
} }
@ -145,15 +145,15 @@ class StatusActionBar extends ImmutablePureComponent {
}; };
handleDeleteClick = () => { handleDeleteClick = () => {
this.props.onDelete(this.props.status, this.props.history); this.props.onDelete(this.props.status);
}; };
handleRedraftClick = () => { handleRedraftClick = () => {
this.props.onDelete(this.props.status, this.props.history, true); this.props.onDelete(this.props.status, true);
}; };
handleEditClick = () => { handleEditClick = () => {
this.props.onEdit(this.props.status, this.props.history); this.props.onEdit(this.props.status);
}; };
handlePinClick = () => { handlePinClick = () => {
@ -161,11 +161,11 @@ class StatusActionBar extends ImmutablePureComponent {
}; };
handleMentionClick = () => { handleMentionClick = () => {
this.props.onMention(this.props.status.get('account'), this.props.history); this.props.onMention(this.props.status.get('account'));
}; };
handleDirectClick = () => { handleDirectClick = () => {
this.props.onDirect(this.props.status.get('account'), this.props.history); this.props.onDirect(this.props.status.get('account'));
}; };
handleMuteClick = () => { handleMuteClick = () => {

View File

@ -93,7 +93,7 @@ const makeMapStateToProps = () => {
const mapDispatchToProps = (dispatch, { intl, contextType }) => ({ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
onReply (status, router) { onReply (status) {
dispatch((_, getState) => { dispatch((_, getState) => {
let state = getState(); let state = getState();
@ -104,11 +104,11 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
message: intl.formatMessage(messages.replyMessage), message: intl.formatMessage(messages.replyMessage),
confirm: intl.formatMessage(messages.replyConfirm), confirm: intl.formatMessage(messages.replyConfirm),
onDoNotAsk: () => dispatch(changeLocalSetting(['confirm_before_clearing_draft'], false)), onDoNotAsk: () => dispatch(changeLocalSetting(['confirm_before_clearing_draft'], false)),
onConfirm: () => dispatch(replyCompose(status, router)), onConfirm: () => dispatch(replyCompose(status)),
}, },
})); }));
} else { } else {
dispatch(replyCompose(status, router)); dispatch(replyCompose(status));
} }
}); });
}, },
@ -182,22 +182,22 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
})); }));
}, },
onDelete (status, history, withRedraft = false) { onDelete (status, withRedraft = false) {
if (!deleteModal) { if (!deleteModal) {
dispatch(deleteStatus(status.get('id'), history, withRedraft)); dispatch(deleteStatus(status.get('id'), withRedraft));
} else { } else {
dispatch(openModal({ dispatch(openModal({
modalType: 'CONFIRM', modalType: 'CONFIRM',
modalProps: { modalProps: {
message: intl.formatMessage(withRedraft ? messages.redraftMessage : messages.deleteMessage), message: intl.formatMessage(withRedraft ? messages.redraftMessage : messages.deleteMessage),
confirm: intl.formatMessage(withRedraft ? messages.redraftConfirm : messages.deleteConfirm), confirm: intl.formatMessage(withRedraft ? messages.redraftConfirm : messages.deleteConfirm),
onConfirm: () => dispatch(deleteStatus(status.get('id'), history, withRedraft)), onConfirm: () => dispatch(deleteStatus(status.get('id'), withRedraft)),
}, },
})); }));
} }
}, },
onEdit (status, history) { onEdit (status) {
dispatch((_, getState) => { dispatch((_, getState) => {
let state = getState(); let state = getState();
if (state.getIn(['compose', 'text']).trim().length !== 0) { if (state.getIn(['compose', 'text']).trim().length !== 0) {
@ -206,11 +206,11 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
modalProps: { modalProps: {
message: intl.formatMessage(messages.editMessage), message: intl.formatMessage(messages.editMessage),
confirm: intl.formatMessage(messages.editConfirm), confirm: intl.formatMessage(messages.editConfirm),
onConfirm: () => dispatch(editStatus(status.get('id'), history)), onConfirm: () => dispatch(editStatus(status.get('id'))),
}, },
})); }));
} else { } else {
dispatch(editStatus(status.get('id'), history)); dispatch(editStatus(status.get('id')));
} }
}); });
}, },
@ -223,12 +223,12 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
} }
}, },
onDirect (account, router) { onDirect (account) {
dispatch(directCompose(account, router)); dispatch(directCompose(account));
}, },
onMention (account, router) { onMention (account) {
dispatch(mentionCompose(account, router)); dispatch(mentionCompose(account));
}, },
onOpenMedia (statusId, media, index, lang) { onOpenMedia (statusId, media, index, lang) {

View File

@ -2,13 +2,11 @@ import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl'; import { FormattedMessage } from 'react-intl';
import { NavLink, withRouter } from 'react-router-dom'; import { NavLink } from 'react-router-dom';
import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component'; import ImmutablePureComponent from 'react-immutable-pure-component';
import { WithRouterPropTypes } from 'flavours/glitch/utils/react_router';
import ActionBar from '../../account/components/action_bar'; import ActionBar from '../../account/components/action_bar';
import InnerHeader from '../../account/components/header'; import InnerHeader from '../../account/components/header';
@ -36,7 +34,6 @@ class Header extends ImmutablePureComponent {
hideTabs: PropTypes.bool, hideTabs: PropTypes.bool,
domain: PropTypes.string.isRequired, domain: PropTypes.string.isRequired,
hidden: PropTypes.bool, hidden: PropTypes.bool,
...WithRouterPropTypes,
}; };
handleFollow = () => { handleFollow = () => {
@ -48,11 +45,11 @@ class Header extends ImmutablePureComponent {
}; };
handleMention = () => { handleMention = () => {
this.props.onMention(this.props.account, this.props.history); this.props.onMention(this.props.account);
}; };
handleDirect = () => { handleDirect = () => {
this.props.onDirect(this.props.account, this.props.history); this.props.onDirect(this.props.account);
}; };
handleReport = () => { handleReport = () => {
@ -158,4 +155,4 @@ class Header extends ImmutablePureComponent {
} }
export default withRouter(Header); export default Header;

View File

@ -75,12 +75,12 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
} }
}, },
onMention (account, router) { onMention (account) {
dispatch(mentionCompose(account, router)); dispatch(mentionCompose(account));
}, },
onDirect (account, router) { onDirect (account) {
dispatch(directCompose(account, router)); dispatch(directCompose(account));
}, },
onReblogToggle (account) { onReblogToggle (account) {

View File

@ -10,8 +10,6 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
import { length } from 'stringz'; import { length } from 'stringz';
import { WithOptionalRouterPropTypes, withOptionalRouter } from 'flavours/glitch/utils/react_router';
import AutosuggestInput from '../../../components/autosuggest_input'; import AutosuggestInput from '../../../components/autosuggest_input';
import AutosuggestTextarea from '../../../components/autosuggest_textarea'; import AutosuggestTextarea from '../../../components/autosuggest_textarea';
import { Button } from '../../../components/button'; import { Button } from '../../../components/button';
@ -81,7 +79,6 @@ class ComposeForm extends ImmutablePureComponent {
singleColumn: PropTypes.bool, singleColumn: PropTypes.bool,
lang: PropTypes.string, lang: PropTypes.string,
maxChars: PropTypes.number, maxChars: PropTypes.number,
...WithOptionalRouterPropTypes
}; };
static defaultProps = { static defaultProps = {
@ -141,9 +138,9 @@ class ComposeForm extends ImmutablePureComponent {
// Submit unless there are media with missing descriptions // Submit unless there are media with missing descriptions
if (this.props.mediaDescriptionConfirmation && this.props.media && this.props.media.some(item => !item.get('description'))) { if (this.props.mediaDescriptionConfirmation && this.props.media && this.props.media.some(item => !item.get('description'))) {
const firstWithoutDescription = this.props.media.find(item => !item.get('description')); const firstWithoutDescription = this.props.media.find(item => !item.get('description'));
this.props.onMediaDescriptionConfirm(this.props.history || null, firstWithoutDescription.get('id'), overridePrivacy); this.props.onMediaDescriptionConfirm(firstWithoutDescription.get('id'), overridePrivacy);
} else { } else {
this.props.onSubmit(this.props.history || null, overridePrivacy); this.props.onSubmit(overridePrivacy);
} }
}; };
@ -351,4 +348,4 @@ class ComposeForm extends ImmutablePureComponent {
} }
export default withOptionalRouter(injectIntl(ComposeForm)); export default injectIntl(ComposeForm);

View File

@ -82,8 +82,8 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
dispatch(changeCompose(text)); dispatch(changeCompose(text));
}, },
onSubmit (router, overridePrivacy = null) { onSubmit (overridePrivacy = null) {
dispatch(submitCompose(router, overridePrivacy)); dispatch(submitCompose(overridePrivacy));
}, },
onClearSuggestions () { onClearSuggestions () {
@ -110,14 +110,14 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
dispatch(insertEmojiCompose(position, data, needsSpace)); dispatch(insertEmojiCompose(position, data, needsSpace));
}, },
onMediaDescriptionConfirm (routerHistory, mediaId, overridePrivacy = null) { onMediaDescriptionConfirm (mediaId, overridePrivacy = null) {
dispatch(openModal({ dispatch(openModal({
modalType: 'CONFIRM', modalType: 'CONFIRM',
modalProps: { modalProps: {
message: intl.formatMessage(messages.missingDescriptionMessage), message: intl.formatMessage(messages.missingDescriptionMessage),
confirm: intl.formatMessage(messages.missingDescriptionConfirm), confirm: intl.formatMessage(messages.missingDescriptionConfirm),
onConfirm: () => { onConfirm: () => {
dispatch(submitCompose(routerHistory, overridePrivacy)); dispatch(submitCompose(overridePrivacy));
}, },
secondary: intl.formatMessage(messages.missingDescriptionEdit), secondary: intl.formatMessage(messages.missingDescriptionEdit),
onSecondary: () => dispatch(openModal({ onSecondary: () => dispatch(openModal({

View File

@ -126,14 +126,14 @@ export const Conversation = ({ conversation, scrollKey, onMoveUp, onMoveDown })
modalProps: { modalProps: {
message: intl.formatMessage(messages.replyMessage), message: intl.formatMessage(messages.replyMessage),
confirm: intl.formatMessage(messages.replyConfirm), confirm: intl.formatMessage(messages.replyConfirm),
onConfirm: () => dispatch(replyCompose(lastStatus, history)), onConfirm: () => dispatch(replyCompose(lastStatus)),
}, },
})); }));
} else { } else {
dispatch(replyCompose(lastStatus, history)); dispatch(replyCompose(lastStatus));
} }
}); });
}, [dispatch, lastStatus, history, intl]); }, [dispatch, lastStatus, intl]);
const handleDelete = useCallback(() => { const handleDelete = useCallback(() => {
dispatch(deleteConversation(id)); dispatch(deleteConversation(id));

View File

@ -92,7 +92,7 @@ class Notification extends ImmutablePureComponent {
e.preventDefault(); e.preventDefault();
const { notification, onMention } = this.props; const { notification, onMention } = this.props;
onMention(notification.get('account'), this.props.history); onMention(notification.get('account'));
}; };
handleHotkeyFavourite = () => { handleHotkeyFavourite = () => {

View File

@ -31,8 +31,8 @@ const makeMapStateToProps = () => {
}; };
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
onMention: (account, router) => { onMention: (account) => {
dispatch(mentionCompose(account, router)); dispatch(mentionCompose(account));
}, },
onModalReblog (status, privacy) { onModalReblog (status, privacy) {

View File

@ -3,7 +3,7 @@ import { useCallback } from 'react';
import { FormattedMessage, useIntl, defineMessages } from 'react-intl'; import { FormattedMessage, useIntl, defineMessages } from 'react-intl';
import { Helmet } from 'react-helmet'; import { Helmet } from 'react-helmet';
import { Link, Switch, Route, useHistory } from 'react-router-dom'; import { Link, Switch, Route } from 'react-router-dom';
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';
@ -34,11 +34,10 @@ const Onboarding = () => {
const account = useAppSelector(state => state.getIn(['accounts', me])); const account = useAppSelector(state => state.getIn(['accounts', me]));
const dispatch = useDispatch(); const dispatch = useDispatch();
const intl = useIntl(); const intl = useIntl();
const history = useHistory();
const handleComposeClick = useCallback(() => { const handleComposeClick = useCallback(() => {
dispatch(focusCompose(history, intl.formatMessage(messages.template))); dispatch(focusCompose(intl.formatMessage(messages.template)));
}, [dispatch, intl, history]); }, [dispatch, intl]);
return ( return (
<Column> <Column>

View File

@ -63,13 +63,13 @@ class Footer extends ImmutablePureComponent {
}; };
_performReply = () => { _performReply = () => {
const { dispatch, status, onClose, history } = this.props; const { dispatch, status, onClose } = this.props;
if (onClose) { if (onClose) {
onClose(true); onClose(true);
} }
dispatch(replyCompose(status, history)); dispatch(replyCompose(status));
}; };
handleReplyClick = () => { handleReplyClick = () => {

View File

@ -4,7 +4,6 @@ import { PureComponent } from 'react';
import { defineMessages, injectIntl } from 'react-intl'; import { defineMessages, injectIntl } from 'react-intl';
import classNames from 'classnames'; import classNames from 'classnames';
import { withRouter } from 'react-router-dom';
import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePropTypes from 'react-immutable-proptypes';
@ -23,7 +22,6 @@ import RepeatPrivateActiveIcon from '@/svg-icons/repeat_private_active.svg?react
import { identityContextPropShape, withIdentity } from 'flavours/glitch/identity_context'; import { identityContextPropShape, withIdentity } from 'flavours/glitch/identity_context';
import { PERMISSION_MANAGE_USERS, PERMISSION_MANAGE_FEDERATION } from 'flavours/glitch/permissions'; import { PERMISSION_MANAGE_USERS, PERMISSION_MANAGE_FEDERATION } from 'flavours/glitch/permissions';
import { accountAdminLink, statusAdminLink } from 'flavours/glitch/utils/backend_links'; import { accountAdminLink, statusAdminLink } from 'flavours/glitch/utils/backend_links';
import { WithRouterPropTypes } from 'flavours/glitch/utils/react_router';
import { IconButton } from '../../../components/icon_button'; import { IconButton } from '../../../components/icon_button';
import DropdownMenuContainer from '../../../containers/dropdown_menu_container'; import DropdownMenuContainer from '../../../containers/dropdown_menu_container';
@ -78,7 +76,6 @@ class ActionBar extends PureComponent {
onPin: PropTypes.func, onPin: PropTypes.func,
onEmbed: PropTypes.func, onEmbed: PropTypes.func,
intl: PropTypes.object.isRequired, intl: PropTypes.object.isRequired,
...WithRouterPropTypes,
}; };
handleReplyClick = () => { handleReplyClick = () => {
@ -98,23 +95,23 @@ class ActionBar extends PureComponent {
}; };
handleDeleteClick = () => { handleDeleteClick = () => {
this.props.onDelete(this.props.status, this.props.history); this.props.onDelete(this.props.status);
}; };
handleRedraftClick = () => { handleRedraftClick = () => {
this.props.onDelete(this.props.status, this.props.history, true); this.props.onDelete(this.props.status, true);
}; };
handleEditClick = () => { handleEditClick = () => {
this.props.onEdit(this.props.status, this.props.history); this.props.onEdit(this.props.status);
}; };
handleDirectClick = () => { handleDirectClick = () => {
this.props.onDirect(this.props.status.get('account'), this.props.history); this.props.onDirect(this.props.status.get('account'));
}; };
handleMentionClick = () => { handleMentionClick = () => {
this.props.onMention(this.props.status.get('account'), this.props.history); this.props.onMention(this.props.status.get('account'));
}; };
handleMuteClick = () => { handleMuteClick = () => {
@ -262,4 +259,4 @@ class ActionBar extends PureComponent {
} }
export default withRouter(withIdentity(injectIntl(ActionBar))); export default withIdentity(injectIntl(ActionBar));

View File

@ -52,7 +52,7 @@ const makeMapStateToProps = () => {
const mapDispatchToProps = (dispatch, { intl }) => ({ const mapDispatchToProps = (dispatch, { intl }) => ({
onReply (status, router) { onReply (status) {
dispatch((_, getState) => { dispatch((_, getState) => {
let state = getState(); let state = getState();
if (state.getIn(['compose', 'text']).trim().length !== 0) { if (state.getIn(['compose', 'text']).trim().length !== 0) {
@ -61,11 +61,11 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
modalProps: { modalProps: {
message: intl.formatMessage(messages.replyMessage), message: intl.formatMessage(messages.replyMessage),
confirm: intl.formatMessage(messages.replyConfirm), confirm: intl.formatMessage(messages.replyConfirm),
onConfirm: () => dispatch(replyCompose(status, router)), onConfirm: () => dispatch(replyCompose(status)),
}, },
})); }));
} else { } else {
dispatch(replyCompose(status, router)); dispatch(replyCompose(status));
} }
}); });
}, },
@ -112,27 +112,27 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
})); }));
}, },
onDelete (status, history, withRedraft = false) { onDelete (status, withRedraft = false) {
if (!deleteModal) { if (!deleteModal) {
dispatch(deleteStatus(status.get('id'), history, withRedraft)); dispatch(deleteStatus(status.get('id'), withRedraft));
} else { } else {
dispatch(openModal({ dispatch(openModal({
modalType: 'CONFIRM', modalType: 'CONFIRM',
modalProps: { modalProps: {
message: intl.formatMessage(withRedraft ? messages.redraftMessage : messages.deleteMessage), message: intl.formatMessage(withRedraft ? messages.redraftMessage : messages.deleteMessage),
confirm: intl.formatMessage(withRedraft ? messages.redraftConfirm : messages.deleteConfirm), confirm: intl.formatMessage(withRedraft ? messages.redraftConfirm : messages.deleteConfirm),
onConfirm: () => dispatch(deleteStatus(status.get('id'), history, withRedraft)), onConfirm: () => dispatch(deleteStatus(status.get('id'), withRedraft)),
}, },
})); }));
} }
}, },
onDirect (account, router) { onDirect (account) {
dispatch(directCompose(account, router)); dispatch(directCompose(account));
}, },
onMention (account, router) { onMention (account) {
dispatch(mentionCompose(account, router)); dispatch(mentionCompose(account));
}, },
onOpenMedia (media, index, lang) { onOpenMedia (media, index, lang) {

View File

@ -324,11 +324,11 @@ class Status extends ImmutablePureComponent {
message: intl.formatMessage(messages.replyMessage), message: intl.formatMessage(messages.replyMessage),
confirm: intl.formatMessage(messages.replyConfirm), confirm: intl.formatMessage(messages.replyConfirm),
onDoNotAsk: () => dispatch(changeLocalSetting(['confirm_before_clearing_draft'], false)), onDoNotAsk: () => dispatch(changeLocalSetting(['confirm_before_clearing_draft'], false)),
onConfirm: () => dispatch(replyCompose(status, this.props.history)), onConfirm: () => dispatch(replyCompose(status)),
}, },
})); }));
} else { } else {
dispatch(replyCompose(status, this.props.history)); dispatch(replyCompose(status));
} }
} else { } else {
dispatch(openModal({ dispatch(openModal({
@ -384,33 +384,33 @@ class Status extends ImmutablePureComponent {
} }
}; };
handleDeleteClick = (status, history, withRedraft = false) => { handleDeleteClick = (status, withRedraft = false) => {
const { dispatch, intl } = this.props; const { dispatch, intl } = this.props;
if (!deleteModal) { if (!deleteModal) {
dispatch(deleteStatus(status.get('id'), history, withRedraft)); dispatch(deleteStatus(status.get('id'), withRedraft));
} else { } else {
dispatch(openModal({ dispatch(openModal({
modalType: 'CONFIRM', modalType: 'CONFIRM',
modalProps: { modalProps: {
message: intl.formatMessage(withRedraft ? messages.redraftMessage : messages.deleteMessage), message: intl.formatMessage(withRedraft ? messages.redraftMessage : messages.deleteMessage),
confirm: intl.formatMessage(withRedraft ? messages.redraftConfirm : messages.deleteConfirm), confirm: intl.formatMessage(withRedraft ? messages.redraftConfirm : messages.deleteConfirm),
onConfirm: () => dispatch(deleteStatus(status.get('id'), history, withRedraft)), onConfirm: () => dispatch(deleteStatus(status.get('id'), withRedraft)),
}, },
})); }));
} }
}; };
handleEditClick = (status, history) => { handleEditClick = (status) => {
this.props.dispatch(editStatus(status.get('id'), history)); this.props.dispatch(editStatus(status.get('id')));
}; };
handleDirectClick = (account, history) => { handleDirectClick = (account) => {
this.props.dispatch(directCompose(account, history)); this.props.dispatch(directCompose(account));
}; };
handleMentionClick = (account, history) => { handleMentionClick = (account) => {
this.props.dispatch(mentionCompose(account, history)); this.props.dispatch(mentionCompose(account));
}; };
handleOpenMedia = (media, index, lang) => { handleOpenMedia = (media, index, lang) => {