mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-17 09:48:42 +00:00
Remove unused bundle-related Redux actions (#37030)
This commit is contained in:
@@ -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,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,6 @@ import PropTypes from 'prop-types';
|
|||||||
import { PureComponent } from 'react';
|
import { PureComponent } from 'react';
|
||||||
|
|
||||||
const emptyComponent = () => null;
|
const emptyComponent = () => null;
|
||||||
const noop = () => { };
|
|
||||||
|
|
||||||
class Bundle extends PureComponent {
|
class Bundle extends PureComponent {
|
||||||
|
|
||||||
@@ -12,18 +11,12 @@ class Bundle extends PureComponent {
|
|||||||
error: PropTypes.func,
|
error: PropTypes.func,
|
||||||
children: PropTypes.func.isRequired,
|
children: PropTypes.func.isRequired,
|
||||||
renderDelay: PropTypes.number,
|
renderDelay: PropTypes.number,
|
||||||
onFetch: PropTypes.func,
|
|
||||||
onFetchSuccess: PropTypes.func,
|
|
||||||
onFetchFail: PropTypes.func,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
loading: emptyComponent,
|
loading: emptyComponent,
|
||||||
error: emptyComponent,
|
error: emptyComponent,
|
||||||
renderDelay: 0,
|
renderDelay: 0,
|
||||||
onFetch: noop,
|
|
||||||
onFetchSuccess: noop,
|
|
||||||
onFetchFail: noop,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static cache = new Map;
|
static cache = new Map;
|
||||||
@@ -50,7 +43,7 @@ class Bundle extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
load = (props) => {
|
load = (props) => {
|
||||||
const { fetchComponent, onFetch, onFetchSuccess, onFetchFail, renderDelay } = props || this.props;
|
const { fetchComponent, renderDelay } = props || this.props;
|
||||||
const cachedMod = Bundle.cache.get(fetchComponent);
|
const cachedMod = Bundle.cache.get(fetchComponent);
|
||||||
|
|
||||||
if (fetchComponent === undefined) {
|
if (fetchComponent === undefined) {
|
||||||
@@ -58,11 +51,8 @@ class Bundle extends PureComponent {
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
onFetch();
|
|
||||||
|
|
||||||
if (cachedMod) {
|
if (cachedMod) {
|
||||||
this.setState({ mod: cachedMod.default });
|
this.setState({ mod: cachedMod.default });
|
||||||
onFetchSuccess();
|
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,11 +67,9 @@ class Bundle extends PureComponent {
|
|||||||
.then((mod) => {
|
.then((mod) => {
|
||||||
Bundle.cache.set(fetchComponent, mod);
|
Bundle.cache.set(fetchComponent, mod);
|
||||||
this.setState({ mod: mod.default });
|
this.setState({ mod: mod.default });
|
||||||
onFetchSuccess();
|
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
this.setState({ mod: null });
|
this.setState({ mod: null });
|
||||||
onFetchFail(error);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
|||||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||||
|
|
||||||
import { scrollRight } from '../../../scroll';
|
import { scrollRight } from '../../../scroll';
|
||||||
import BundleContainer from '../containers/bundle_container';
|
|
||||||
import {
|
import {
|
||||||
Compose,
|
Compose,
|
||||||
Notifications,
|
Notifications,
|
||||||
@@ -21,6 +20,7 @@ import {
|
|||||||
} from '../util/async-components';
|
} from '../util/async-components';
|
||||||
import { useColumnsContext } from '../util/columns_context';
|
import { useColumnsContext } from '../util/columns_context';
|
||||||
|
|
||||||
|
import Bundle from './bundle';
|
||||||
import BundleColumnError from './bundle_column_error';
|
import BundleColumnError from './bundle_column_error';
|
||||||
import { ColumnLoading } from './column_loading';
|
import { ColumnLoading } from './column_loading';
|
||||||
import { ComposePanel, RedirectToMobileComposeIfNeeded } from './compose_panel';
|
import { ComposePanel, RedirectToMobileComposeIfNeeded } from './compose_panel';
|
||||||
@@ -145,9 +145,9 @@ export default class ColumnsArea extends ImmutablePureComponent {
|
|||||||
const other = params && params.other ? params.other : {};
|
const other = params && params.other ? params.other : {};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BundleContainer key={column.get('uuid')} fetchComponent={componentMap[column.get('id')]} loading={this.renderLoading(column.get('id'))} error={this.renderError}>
|
<Bundle key={column.get('uuid')} fetchComponent={componentMap[column.get('id')]} loading={this.renderLoading(column.get('id'))} error={this.renderError}>
|
||||||
{SpecificComponent => <SpecificComponent columnId={column.get('uuid')} params={params} multiColumn {...other} />}
|
{SpecificComponent => <SpecificComponent columnId={column.get('uuid')} params={params} multiColumn {...other} />}
|
||||||
</BundleContainer>
|
</Bundle>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
||||||
|
|||||||
@@ -21,11 +21,10 @@ import {
|
|||||||
AnnualReportModal,
|
AnnualReportModal,
|
||||||
} from 'mastodon/features/ui/util/async-components';
|
} from 'mastodon/features/ui/util/async-components';
|
||||||
|
|
||||||
import BundleContainer from '../containers/bundle_container';
|
|
||||||
|
|
||||||
import { ActionsModal } from './actions_modal';
|
import { ActionsModal } from './actions_modal';
|
||||||
import AudioModal from './audio_modal';
|
import AudioModal from './audio_modal';
|
||||||
import { BoostModal } from './boost_modal';
|
import { BoostModal } from './boost_modal';
|
||||||
|
import Bundle from './bundle';
|
||||||
import {
|
import {
|
||||||
ConfirmationModal,
|
ConfirmationModal,
|
||||||
ConfirmDeleteStatusModal,
|
ConfirmDeleteStatusModal,
|
||||||
@@ -136,11 +135,11 @@ export default class ModalRoot extends PureComponent {
|
|||||||
<Base backgroundColor={backgroundColor} onClose={this.handleClose} ignoreFocus={ignoreFocus}>
|
<Base backgroundColor={backgroundColor} onClose={this.handleClose} ignoreFocus={ignoreFocus}>
|
||||||
{visible && (
|
{visible && (
|
||||||
<>
|
<>
|
||||||
<BundleContainer key={type} fetchComponent={MODAL_COMPONENTS[type]} loading={this.renderLoading} error={this.renderError} renderDelay={200}>
|
<Bundle key={type} fetchComponent={MODAL_COMPONENTS[type]} loading={this.renderLoading} error={this.renderError} renderDelay={200}>
|
||||||
{(SpecificComponent) => {
|
{(SpecificComponent) => {
|
||||||
return <SpecificComponent {...props} onChangeBackgroundColor={this.setBackgroundColor} onClose={this.handleClose} ref={this.setModalRef} />;
|
return <SpecificComponent {...props} onChangeBackgroundColor={this.setBackgroundColor} onClose={this.handleClose} ref={this.setModalRef} />;
|
||||||
}}
|
}}
|
||||||
</BundleContainer>
|
</Bundle>
|
||||||
|
|
||||||
<Helmet>
|
<Helmet>
|
||||||
<meta name='robots' content='noindex' />
|
<meta name='robots' content='noindex' />
|
||||||
|
|||||||
@@ -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);
|
|
||||||
@@ -5,9 +5,9 @@ import { Switch, Route, useLocation } from 'react-router-dom';
|
|||||||
|
|
||||||
import StackTrace from 'stacktrace-js';
|
import StackTrace from 'stacktrace-js';
|
||||||
|
|
||||||
|
import Bundle from '../components/bundle';
|
||||||
import BundleColumnError from '../components/bundle_column_error';
|
import BundleColumnError from '../components/bundle_column_error';
|
||||||
import { ColumnLoading } from '../components/column_loading';
|
import { ColumnLoading } from '../components/column_loading';
|
||||||
import BundleContainer from '../containers/bundle_container';
|
|
||||||
|
|
||||||
// Small wrapper to pass multiColumn to the route components
|
// Small wrapper to pass multiColumn to the route components
|
||||||
export const WrappedSwitch = ({ multiColumn, children }) => {
|
export const WrappedSwitch = ({ multiColumn, children }) => {
|
||||||
@@ -80,9 +80,9 @@ export class WrappedRoute extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BundleContainer fetchComponent={component} loading={this.renderLoading} error={this.renderError}>
|
<Bundle fetchComponent={component} loading={this.renderLoading} error={this.renderError}>
|
||||||
{Component => <Component params={match.params} multiColumn={multiColumn} {...componentParams}>{content}</Component>}
|
{Component => <Component params={match.params} multiColumn={multiColumn} {...componentParams}>{content}</Component>}
|
||||||
</BundleContainer>
|
</Bundle>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user