[Glitch] Upgrade to react-router v5

Port 1b70d7ed7c to glitch-soc

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Renaud ChaputandClaire authored and Claire committed 2023-10-21 22:14:24 +02:00
1 parent 245513d630
commit d6eacb79c6
51 files changed
+413 -385

No files matched your search

@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import classNames from 'classnames';
import { withRouter } from 'react-router-dom';
import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
@@ -17,6 +18,7 @@ import { RelativeTimestamp } from 'flavours/glitch/components/relative_timestamp
import StatusContent from 'flavours/glitch/components/status_content';
import DropdownMenuContainer from 'flavours/glitch/containers/dropdown_menu_container';
import { autoPlayGif } from 'flavours/glitch/initial_state';
import { WithRouterPropTypes } from 'flavours/glitch/utils/react_router';
const messages = defineMessages({
more: { id: 'status.more', defaultMessage: 'More' },
@@ -30,10 +32,6 @@ const messages = defineMessages({
class Conversation extends ImmutablePureComponent {
static contextTypes = {
router: PropTypes.object,
};
static propTypes = {
conversationId: PropTypes.string.isRequired,
accounts: ImmutablePropTypes.list.isRequired,
@@ -45,6 +43,7 @@ class Conversation extends ImmutablePureComponent {
markRead: PropTypes.func.isRequired,
delete: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
...WithRouterPropTypes,
};
state = {
@@ -52,9 +51,8 @@ class Conversation extends ImmutablePureComponent {
};
parseClick = (e, destination) => {
const { router } = this.context;
const { lastStatus, unread, markRead } = this.props;
if (!router) return;
const { history, lastStatus, unread, markRead } = this.props;
if (!history) return;
if (e.button === 0 && !(e.ctrlKey || e.altKey || e.metaKey)) {
if (destination === undefined) {
@@ -63,7 +61,7 @@ class Conversation extends ImmutablePureComponent {
}
destination = `/statuses/${lastStatus.get('id')}`;
}
router.history.push(destination);
history.push(destination);
e.preventDefault();
}
};
@@ -95,7 +93,7 @@ class Conversation extends ImmutablePureComponent {
};
handleClick = () => {
if (!this.context.router) {
if (!this.props.history) {
return;
}
@@ -105,7 +103,7 @@ class Conversation extends ImmutablePureComponent {
markRead();
}
this.context.router.history.push(`/@${lastStatus.getIn(['account', 'acct'])}/${lastStatus.get('id')}`);
this.props.history.push(`/@${lastStatus.getIn(['account', 'acct'])}/${lastStatus.get('id')}`);
};
handleMarkAsRead = () => {
@@ -113,7 +111,7 @@ class Conversation extends ImmutablePureComponent {
};
handleReply = () => {
this.props.reply(this.props.lastStatus, this.context.router.history);
this.props.reply(this.props.lastStatus, this.props.history);
};
handleDelete = () => {
@@ -232,4 +230,4 @@ class Conversation extends ImmutablePureComponent {
}
export default injectIntl(Conversation);
export default withRouter(injectIntl(Conversation));