Merge branch 'react-router-hooks' into 'next'
Use React Router hook for 'history' See merge request soapbox-pub/soapbox-fe!1127
This commit is contained in:
commit
61d78053cd
12 changed files with 54 additions and 89 deletions
|
@ -119,7 +119,7 @@ const Account = ({
|
|||
);
|
||||
}
|
||||
|
||||
const LinkEl = showProfileHoverCard ? Link : 'div';
|
||||
const LinkEl: any = showProfileHoverCard ? Link : 'div';
|
||||
|
||||
return (
|
||||
<div className='flex-shrink-0 group block w-full overflow-hidden' ref={overflowRef}>
|
||||
|
@ -132,7 +132,7 @@ const Account = ({
|
|||
<LinkEl
|
||||
to={`/@${account.get('acct')}`}
|
||||
title={account.get('acct')}
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
onClick={(event: React.MouseEvent) => event.stopPropagation()}
|
||||
>
|
||||
<Avatar src={account.get('avatar')} size={avatarSize} />
|
||||
</LinkEl>
|
||||
|
@ -146,7 +146,7 @@ const Account = ({
|
|||
<LinkEl
|
||||
to={`/@${account.get('acct')}`}
|
||||
title={account.get('acct')}
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
onClick={(event: React.MouseEvent) => event.stopPropagation()}
|
||||
>
|
||||
<div className='flex items-center space-x-1 flex-grow' style={style}>
|
||||
<Text
|
||||
|
|
|
@ -5,7 +5,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
|||
import { useIntl } from 'react-intl';
|
||||
import { usePopper } from 'react-popper';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import { fetchRelationships } from 'soapbox/actions/accounts';
|
||||
import {
|
||||
|
@ -52,8 +52,9 @@ const handleMouseLeave = (dispatch) => {
|
|||
};
|
||||
};
|
||||
|
||||
export const ProfileHoverCard = ({ history, visible }) => {
|
||||
export const ProfileHoverCard = ({ visible }) => {
|
||||
const dispatch = useDispatch();
|
||||
const history = useHistory();
|
||||
const intl = useIntl();
|
||||
|
||||
const [popperElement, setPopperElement] = useState(null);
|
||||
|
@ -134,11 +135,10 @@ ProfileHoverCard.propTypes = {
|
|||
visible: PropTypes.bool,
|
||||
accountId: PropTypes.string,
|
||||
account: ImmutablePropTypes.map,
|
||||
history: PropTypes.object.isRequired,
|
||||
};
|
||||
|
||||
ProfileHoverCard.defaultProps = {
|
||||
visible: true,
|
||||
};
|
||||
|
||||
export default withRouter(ProfileHoverCard);
|
||||
export default ProfileHoverCard;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import React from 'react';
|
||||
import { RouteComponentProps, withRouter } from 'react-router-dom';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import Helmet from 'soapbox/components/helmet';
|
||||
|
||||
import { Card, CardBody, CardHeader, CardTitle } from '../card/card';
|
||||
|
||||
interface IColumn extends RouteComponentProps {
|
||||
interface IColumn {
|
||||
backHref?: string,
|
||||
label?: string,
|
||||
transparent?: boolean,
|
||||
|
@ -13,7 +13,9 @@ interface IColumn extends RouteComponentProps {
|
|||
}
|
||||
|
||||
const Column: React.FC<IColumn> = React.forwardRef((props, ref: React.ForwardedRef<HTMLDivElement>): JSX.Element => {
|
||||
const { backHref, children, label, history, transparent = false, withHeader = true } = props;
|
||||
const { backHref, children, label, transparent = false, withHeader = true } = props;
|
||||
|
||||
const history = useHistory();
|
||||
|
||||
const handleBackClick = () => {
|
||||
if (backHref) {
|
||||
|
@ -57,4 +59,4 @@ const Column: React.FC<IColumn> = React.forwardRef((props, ref: React.ForwardedR
|
|||
);
|
||||
});
|
||||
|
||||
export default withRouter(Column);
|
||||
export default Column;
|
||||
|
|
|
@ -7,7 +7,7 @@ import {
|
|||
} from '@reach/tabs';
|
||||
import classNames from 'classnames';
|
||||
import * as React from 'react';
|
||||
import { RouteComponentProps, withRouter } from 'react-router-dom';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import './tabs.css';
|
||||
|
||||
|
@ -87,14 +87,16 @@ type Item = {
|
|||
action?: () => void,
|
||||
name: string
|
||||
}
|
||||
interface ITabs extends RouteComponentProps<any> {
|
||||
interface ITabs {
|
||||
items: Item[],
|
||||
activeItem: string,
|
||||
}
|
||||
|
||||
const Tabs = ({ items, activeItem, history }: ITabs) => {
|
||||
const Tabs = ({ items, activeItem }: ITabs) => {
|
||||
const defaultIndex = items.findIndex(({ name }) => name === activeItem);
|
||||
|
||||
const history = useHistory();
|
||||
|
||||
const onChange = (selectedIndex: number) => {
|
||||
const item = items[selectedIndex];
|
||||
|
||||
|
@ -130,4 +132,4 @@ const Tabs = ({ items, activeItem, history }: ITabs) => {
|
|||
);
|
||||
};
|
||||
|
||||
export default withRouter(Tabs);
|
||||
export default Tabs;
|
||||
|
|
|
@ -5,7 +5,7 @@ import * as React from 'react';
|
|||
import InlineSVG from 'react-inlinesvg';
|
||||
import { defineMessages, useIntl } from 'react-intl';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { RouteComponentProps, withRouter } from 'react-router-dom';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import AutosuggestAccountInput from 'soapbox/components/autosuggest_account_input';
|
||||
import { useAppSelector } from 'soapbox/hooks';
|
||||
|
@ -32,7 +32,7 @@ function redirectToAccount(accountId: number, routerHistory: any) {
|
|||
};
|
||||
}
|
||||
|
||||
interface ISearch extends RouteComponentProps<any> {
|
||||
interface ISearch {
|
||||
autoFocus?: boolean,
|
||||
autoSubmit?: boolean,
|
||||
autosuggest?: boolean,
|
||||
|
@ -44,11 +44,11 @@ const Search = (props: ISearch) => {
|
|||
autoFocus = false,
|
||||
autoSubmit = false,
|
||||
autosuggest = false,
|
||||
history,
|
||||
openInRoute = false,
|
||||
} = props;
|
||||
|
||||
const dispatch = useDispatch();
|
||||
const history = useHistory();
|
||||
const intl = useIntl();
|
||||
|
||||
const value = useAppSelector((state) => state.search.get('value'));
|
||||
|
@ -156,4 +156,4 @@ const Search = (props: ISearch) => {
|
|||
);
|
||||
};
|
||||
|
||||
export default withRouter(Search);
|
||||
export default Search;
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import InlineSVG from 'react-inlinesvg';
|
||||
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { Link, withRouter } from 'react-router-dom';
|
||||
import { Link, useHistory } from 'react-router-dom';
|
||||
|
||||
import { changeSettingImmediate } from 'soapbox/actions/settings';
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
|
@ -16,9 +15,10 @@ const messages = defineMessages({
|
|||
leave: { id: 'developers.leave', defaultMessage: 'You have left developers' },
|
||||
});
|
||||
|
||||
const Developers = ({ history }) => {
|
||||
const intl = useIntl();
|
||||
const Developers = () => {
|
||||
const dispatch = useDispatch();
|
||||
const history = useHistory();
|
||||
const intl = useIntl();
|
||||
|
||||
const leaveDevelopers = (e) => {
|
||||
e.preventDefault();
|
||||
|
@ -67,8 +67,4 @@ const Developers = ({ history }) => {
|
|||
);
|
||||
};
|
||||
|
||||
Developers.propTypes = {
|
||||
history: PropTypes.object,
|
||||
};
|
||||
|
||||
export default withRouter(Developers);
|
||||
export default Developers;
|
||||
|
|
|
@ -3,7 +3,7 @@ import React from 'react';
|
|||
import { HotKeys } from 'react-hotkeys';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import { FormattedMessage, useIntl } from 'react-intl';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import Icon from '../../../components/icon';
|
||||
import Permalink from '../../../components/permalink';
|
||||
|
@ -77,9 +77,11 @@ const buildMessage = (type, account) => {
|
|||
};
|
||||
|
||||
const Notification = (props) => {
|
||||
const { hidden, history, notification, onMoveUp, onMoveDown } = props;
|
||||
const { hidden, notification, onMoveUp, onMoveDown } = props;
|
||||
|
||||
const history = useHistory();
|
||||
const intl = useIntl();
|
||||
|
||||
const type = notification.get('type');
|
||||
const timestamp = notification.get('created_at');
|
||||
const account = notification.get('account');
|
||||
|
@ -226,7 +228,6 @@ const Notification = (props) => {
|
|||
|
||||
Notification.propTypes = {
|
||||
hidden: PropTypes.bool,
|
||||
history: PropTypes.object.isRequired,
|
||||
notification: ImmutablePropTypes.map.isRequired,
|
||||
onMoveUp: PropTypes.func.isRequired,
|
||||
onMoveDown: PropTypes.func.isRequired,
|
||||
|
@ -241,4 +242,4 @@ Notification.propTypes = {
|
|||
siteTitle: PropTypes.string,
|
||||
};
|
||||
|
||||
export default withRouter(Notification);
|
||||
export default Notification;
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import PropTypes from 'prop-types';
|
||||
import * as React from 'react';
|
||||
import { defineMessages, useIntl } from 'react-intl';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
|
||||
import { fetchMfa } from 'soapbox/actions/mfa';
|
||||
|
||||
|
@ -22,9 +21,11 @@ const messages = defineMessages({
|
|||
deleteAccount: { id: 'settings.delete_account', defaultMessage: 'Delete Account' },
|
||||
});
|
||||
|
||||
const Settings = ({ history }) => {
|
||||
const intl = useIntl();
|
||||
const Settings = () => {
|
||||
const dispatch = useDispatch();
|
||||
const history = useHistory();
|
||||
const intl = useIntl();
|
||||
|
||||
const mfa = useSelector((state) => state.getIn(['security', 'mfa']));
|
||||
const me = useSelector((state) => state.get('me'));
|
||||
const account = useSelector((state) => state.getIn(['accounts', me]));
|
||||
|
@ -92,8 +93,4 @@ const Settings = ({ history }) => {
|
|||
);
|
||||
};
|
||||
|
||||
Settings.propTypes = {
|
||||
history: PropTypes.object,
|
||||
};
|
||||
|
||||
export default withRouter(Settings);
|
||||
export default Settings;
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import { defineMessages, useIntl } from 'react-intl';
|
||||
import { connect } from 'react-redux';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
import { useDispatch } from 'react-redux';
|
||||
|
||||
import { getSettings, changeSettingImmediate } from 'soapbox/actions/settings';
|
||||
import {
|
||||
SimpleForm,
|
||||
SelectDropdown,
|
||||
} from 'soapbox/features/forms';
|
||||
import { useAppSelector } from 'soapbox/hooks';
|
||||
|
||||
import List, { ListItem } from '../../components/list';
|
||||
import { Card, CardBody, CardHeader, CardTitle } from '../../components/ui';
|
||||
|
@ -21,15 +19,12 @@ const messages = defineMessages({
|
|||
display_media_show_all: { id: 'preferences.fields.display_media.show_all', defaultMessage: 'Always show media' },
|
||||
});
|
||||
|
||||
const mapStateToProps = state => {
|
||||
return {
|
||||
settings: getSettings(state),
|
||||
};
|
||||
};
|
||||
|
||||
const MediaDisplay = ({ history, settings, dispatch }) => {
|
||||
const MediaDisplay = () => {
|
||||
const dispatch = useDispatch();
|
||||
const intl = useIntl();
|
||||
|
||||
const settings = useAppSelector((state) => getSettings(state));
|
||||
|
||||
const displayMediaOptions = {
|
||||
default: intl.formatMessage(messages.display_media_default),
|
||||
hide_all: intl.formatMessage(messages.display_media_hide_all),
|
||||
|
@ -65,10 +60,4 @@ const MediaDisplay = ({ history, settings, dispatch }) => {
|
|||
);
|
||||
};
|
||||
|
||||
MediaDisplay.propTypes = {
|
||||
history: PropTypes.object,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
settings: ImmutablePropTypes.map,
|
||||
};
|
||||
|
||||
export default withRouter(connect(mapStateToProps)(MediaDisplay));
|
||||
export default MediaDisplay;
|
||||
|
|
|
@ -2,7 +2,6 @@ import PropTypes from 'prop-types';
|
|||
import * as React from 'react';
|
||||
import { defineMessages, useIntl } from 'react-intl';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
|
||||
import snackbar from 'soapbox/actions/snackbar';
|
||||
import { confirmEmailVerification } from 'soapbox/actions/verification';
|
||||
|
@ -95,8 +94,8 @@ const TokenExpired = () => {
|
|||
const EmailPassThru = ({ match }) => {
|
||||
const { token } = match.params;
|
||||
|
||||
const intl = useIntl();
|
||||
const dispatch = useDispatch();
|
||||
const intl = useIntl();
|
||||
|
||||
const [status, setStatus] = React.useState(Statuses.IDLE);
|
||||
|
||||
|
@ -160,4 +159,4 @@ EmailPassThru.propTypes = {
|
|||
match: PropTypes.object,
|
||||
};
|
||||
|
||||
export default withRouter(EmailPassThru);
|
||||
export default EmailPassThru;
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
"@types/escape-html": "^1.0.1",
|
||||
"@types/http-link-header": "^1.0.3",
|
||||
"@types/lodash": "^4.14.180",
|
||||
"@types/react-router-dom": "^4.2.6",
|
||||
"@types/react-router-dom": "^5.3.3",
|
||||
"@types/uuid": "^8.3.4",
|
||||
"array-includes": "^3.0.3",
|
||||
"autoprefixer": "^10.4.2",
|
||||
|
|
31
yarn.lock
31
yarn.lock
|
@ -1148,13 +1148,6 @@
|
|||
dependencies:
|
||||
regenerator-runtime "^0.13.4"
|
||||
|
||||
"@babel/runtime@^7.7.6":
|
||||
version "7.17.2"
|
||||
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.2.tgz#66f68591605e59da47523c631416b18508779941"
|
||||
integrity sha512-hzeyJyMA1YGdJTuWU0e/j4wKXrU4OMFvY2MSlaI9B7VQb0r5cxTE3EAIS2Q7Tn2RIcDkRvTA/v2JsAEhxe99uw==
|
||||
dependencies:
|
||||
regenerator-runtime "^0.13.4"
|
||||
|
||||
"@babel/template@7", "@babel/template@^7.16.7":
|
||||
version "7.16.7"
|
||||
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.16.7.tgz#8d126c8701fde4d66b264b3eba3d96f07666d155"
|
||||
|
@ -1989,13 +1982,6 @@
|
|||
dependencies:
|
||||
"@types/node" "*"
|
||||
|
||||
"@types/history@*":
|
||||
version "5.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@types/history/-/history-5.0.0.tgz#29f919f0c8e302763798118f45b19cab4a886f14"
|
||||
integrity sha512-hy8b7Y1J8OGe6LbAjj3xniQrj3v6lsivCcrmf4TzSgPzLkhIeKgc5IZnT7ReIqmEuodjfO8EYAuoFvIrHi/+jQ==
|
||||
dependencies:
|
||||
history "*"
|
||||
|
||||
"@types/history@^4.7.11":
|
||||
version "4.7.11"
|
||||
resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.11.tgz#56588b17ae8f50c53983a524fc3cc47437969d64"
|
||||
|
@ -2119,12 +2105,12 @@
|
|||
hoist-non-react-statics "^3.3.0"
|
||||
redux "^4.0.0"
|
||||
|
||||
"@types/react-router-dom@^4.2.6":
|
||||
version "4.3.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/react-router-dom/-/react-router-dom-4.3.5.tgz#72f229967690c890d00f96e6b85e9ee5780db31f"
|
||||
integrity sha512-eFajSUASYbPHg2BDM1G8Btx+YqGgvROPIg6sBhl3O4kbDdYXdFdfrgQFf/pcBuQVObjfT9AL/dd15jilR5DIEA==
|
||||
"@types/react-router-dom@^5.3.3":
|
||||
version "5.3.3"
|
||||
resolved "https://registry.yarnpkg.com/@types/react-router-dom/-/react-router-dom-5.3.3.tgz#e9d6b4a66fcdbd651a5f106c2656a30088cc1e83"
|
||||
integrity sha512-kpqnYK4wcdm5UaWI3fLcELopqLrHgLqNsdpHauzlQktfkHL3npOSwtj1Uz9oKBAzs7lFtVkV8j83voAz2D8fhw==
|
||||
dependencies:
|
||||
"@types/history" "*"
|
||||
"@types/history" "^4.7.11"
|
||||
"@types/react" "*"
|
||||
"@types/react-router" "*"
|
||||
|
||||
|
@ -5367,13 +5353,6 @@ hex-color-regex@^1.1.0:
|
|||
resolved "https://registry.yarnpkg.com/hex-color-regex/-/hex-color-regex-1.1.0.tgz#4c06fccb4602fe2602b3c93df82d7e7dbf1a8a8e"
|
||||
integrity sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ==
|
||||
|
||||
history@*:
|
||||
version "5.3.0"
|
||||
resolved "https://registry.yarnpkg.com/history/-/history-5.3.0.tgz#1548abaa245ba47992f063a0783db91ef201c73b"
|
||||
integrity sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.7.6"
|
||||
|
||||
history@^4.10.1, history@^4.9.0:
|
||||
version "4.10.1"
|
||||
resolved "https://registry.yarnpkg.com/history/-/history-4.10.1.tgz#33371a65e3a83b267434e2b3f3b1b4c58aad4cf3"
|
||||
|
|
Loading…
Reference in a new issue