diff --git a/app/javascript/mastodon/actions/bundles.js b/app/javascript/mastodon/actions/bundles.js deleted file mode 100644 index ecc9c8f7d3..0000000000 --- a/app/javascript/mastodon/actions/bundles.js +++ /dev/null @@ -1,25 +0,0 @@ -export const BUNDLE_FETCH_REQUEST = 'BUNDLE_FETCH_REQUEST'; -export const BUNDLE_FETCH_SUCCESS = 'BUNDLE_FETCH_SUCCESS'; -export const BUNDLE_FETCH_FAIL = 'BUNDLE_FETCH_FAIL'; - -export function fetchBundleRequest(skipLoading) { - return { - type: BUNDLE_FETCH_REQUEST, - skipLoading, - }; -} - -export function fetchBundleSuccess(skipLoading) { - return { - type: BUNDLE_FETCH_SUCCESS, - skipLoading, - }; -} - -export function fetchBundleFail(error, skipLoading) { - return { - type: BUNDLE_FETCH_FAIL, - error, - skipLoading, - }; -} diff --git a/app/javascript/mastodon/features/ui/components/bundle.jsx b/app/javascript/mastodon/features/ui/components/bundle.jsx index 3617baf4f1..57143f1571 100644 --- a/app/javascript/mastodon/features/ui/components/bundle.jsx +++ b/app/javascript/mastodon/features/ui/components/bundle.jsx @@ -2,7 +2,6 @@ import PropTypes from 'prop-types'; import { PureComponent } from 'react'; const emptyComponent = () => null; -const noop = () => { }; class Bundle extends PureComponent { @@ -12,18 +11,12 @@ class Bundle extends PureComponent { error: PropTypes.func, children: PropTypes.func.isRequired, renderDelay: PropTypes.number, - onFetch: PropTypes.func, - onFetchSuccess: PropTypes.func, - onFetchFail: PropTypes.func, }; static defaultProps = { loading: emptyComponent, error: emptyComponent, renderDelay: 0, - onFetch: noop, - onFetchSuccess: noop, - onFetchFail: noop, }; static cache = new Map; @@ -50,7 +43,7 @@ class Bundle extends PureComponent { } load = (props) => { - const { fetchComponent, onFetch, onFetchSuccess, onFetchFail, renderDelay } = props || this.props; + const { fetchComponent, renderDelay } = props || this.props; const cachedMod = Bundle.cache.get(fetchComponent); if (fetchComponent === undefined) { @@ -58,11 +51,8 @@ class Bundle extends PureComponent { return Promise.resolve(); } - onFetch(); - if (cachedMod) { this.setState({ mod: cachedMod.default }); - onFetchSuccess(); return Promise.resolve(); } @@ -77,11 +67,9 @@ class Bundle extends PureComponent { .then((mod) => { Bundle.cache.set(fetchComponent, mod); this.setState({ mod: mod.default }); - onFetchSuccess(); }) .catch((error) => { this.setState({ mod: null }); - onFetchFail(error); }); }; diff --git a/app/javascript/mastodon/features/ui/components/columns_area.jsx b/app/javascript/mastodon/features/ui/components/columns_area.jsx index 77b95d526a..753f7e9ac3 100644 --- a/app/javascript/mastodon/features/ui/components/columns_area.jsx +++ b/app/javascript/mastodon/features/ui/components/columns_area.jsx @@ -5,7 +5,6 @@ import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { scrollRight } from '../../../scroll'; -import BundleContainer from '../containers/bundle_container'; import { Compose, Notifications, @@ -21,6 +20,7 @@ import { } from '../util/async-components'; import { useColumnsContext } from '../util/columns_context'; +import Bundle from './bundle'; import BundleColumnError from './bundle_column_error'; import { ColumnLoading } from './column_loading'; import { ComposePanel, RedirectToMobileComposeIfNeeded } from './compose_panel'; @@ -145,9 +145,9 @@ export default class ColumnsArea extends ImmutablePureComponent { const other = params && params.other ? params.other : {}; return ( - + {SpecificComponent => } - + ); })} diff --git a/app/javascript/mastodon/features/ui/components/modal_root.jsx b/app/javascript/mastodon/features/ui/components/modal_root.jsx index f8e4c0bb95..6f9b23042d 100644 --- a/app/javascript/mastodon/features/ui/components/modal_root.jsx +++ b/app/javascript/mastodon/features/ui/components/modal_root.jsx @@ -21,11 +21,10 @@ import { AnnualReportModal, } from 'mastodon/features/ui/util/async-components'; -import BundleContainer from '../containers/bundle_container'; - import { ActionsModal } from './actions_modal'; import AudioModal from './audio_modal'; import { BoostModal } from './boost_modal'; +import Bundle from './bundle'; import { ConfirmationModal, ConfirmDeleteStatusModal, @@ -136,11 +135,11 @@ export default class ModalRoot extends PureComponent { {visible && ( <> - + {(SpecificComponent) => { return ; }} - + diff --git a/app/javascript/mastodon/features/ui/containers/bundle_container.js b/app/javascript/mastodon/features/ui/containers/bundle_container.js deleted file mode 100644 index 6a476fe248..0000000000 --- a/app/javascript/mastodon/features/ui/containers/bundle_container.js +++ /dev/null @@ -1,18 +0,0 @@ -import { connect } from 'react-redux'; - -import { fetchBundleRequest, fetchBundleSuccess, fetchBundleFail } from '../../../actions/bundles'; -import Bundle from '../components/bundle'; - -const mapDispatchToProps = dispatch => ({ - onFetch () { - dispatch(fetchBundleRequest()); - }, - onFetchSuccess () { - dispatch(fetchBundleSuccess()); - }, - onFetchFail (error) { - dispatch(fetchBundleFail(error)); - }, -}); - -export default connect(null, mapDispatchToProps)(Bundle); diff --git a/app/javascript/mastodon/features/ui/util/react_router_helpers.jsx b/app/javascript/mastodon/features/ui/util/react_router_helpers.jsx index ec68b5a4a7..3728e2e2e7 100644 --- a/app/javascript/mastodon/features/ui/util/react_router_helpers.jsx +++ b/app/javascript/mastodon/features/ui/util/react_router_helpers.jsx @@ -5,9 +5,9 @@ import { Switch, Route, useLocation } from 'react-router-dom'; import StackTrace from 'stacktrace-js'; +import Bundle from '../components/bundle'; import BundleColumnError from '../components/bundle_column_error'; import { ColumnLoading } from '../components/column_loading'; -import BundleContainer from '../containers/bundle_container'; // Small wrapper to pass multiColumn to the route components export const WrappedSwitch = ({ multiColumn, children }) => { @@ -80,9 +80,9 @@ export class WrappedRoute extends Component { } return ( - + {Component => {content}} - + ); };