kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
fix broken modals
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>strip-front-mentions
rodzic
bf3272d113
commit
b0477ac1e1
|
@ -9,9 +9,10 @@ export function openModal(type, props) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function closeModal(type) {
|
export function closeModal(type, noPop) {
|
||||||
return {
|
return {
|
||||||
type: MODAL_CLOSE,
|
type: MODAL_CLOSE,
|
||||||
modalType: type,
|
modalType: type,
|
||||||
|
noPop,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,6 +45,7 @@ class ModalRoot extends React.PureComponent {
|
||||||
hasComposeContent: PropTypes.bool,
|
hasComposeContent: PropTypes.bool,
|
||||||
type: PropTypes.string,
|
type: PropTypes.string,
|
||||||
onCancel: PropTypes.func,
|
onCancel: PropTypes.func,
|
||||||
|
noPop: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
|
@ -120,7 +121,9 @@ class ModalRoot extends React.PureComponent {
|
||||||
this.activeElement = null;
|
this.activeElement = null;
|
||||||
this.getSiblings().forEach(sibling => sibling.removeAttribute('inert'));
|
this.getSiblings().forEach(sibling => sibling.removeAttribute('inert'));
|
||||||
|
|
||||||
this._handleModalClose();
|
if (!this.props.noPop) {
|
||||||
|
this._handleModalClose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.props.children) {
|
if (this.props.children) {
|
||||||
|
|
|
@ -23,6 +23,10 @@ export default @connect(mapStateToProps)
|
||||||
@injectIntl
|
@injectIntl
|
||||||
class FavouritesModal extends React.PureComponent {
|
class FavouritesModal extends React.PureComponent {
|
||||||
|
|
||||||
|
static contextTypes = {
|
||||||
|
router: PropTypes.object,
|
||||||
|
};
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
onClose: PropTypes.func.isRequired,
|
onClose: PropTypes.func.isRequired,
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
|
@ -40,10 +44,21 @@ class FavouritesModal extends React.PureComponent {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.fetchData();
|
this.fetchData();
|
||||||
|
this.unlistenHistory = this.context.router.history.listen((_, action) => {
|
||||||
|
if (action === 'PUSH') {
|
||||||
|
this.onClickClose(null, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickClose = () => {
|
componentWillUnmount() {
|
||||||
this.props.onClose('FAVOURITES');
|
if (this.unlistenHistory) {
|
||||||
|
this.unlistenHistory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onClickClose = (_, noPop) => {
|
||||||
|
this.props.onClose('FAVOURITES', noPop);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -31,6 +31,10 @@ export default @connect(mapStateToProps)
|
||||||
@injectIntl
|
@injectIntl
|
||||||
class MentionsModal extends React.PureComponent {
|
class MentionsModal extends React.PureComponent {
|
||||||
|
|
||||||
|
static contextTypes = {
|
||||||
|
router: PropTypes.object,
|
||||||
|
};
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
onClose: PropTypes.func.isRequired,
|
onClose: PropTypes.func.isRequired,
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
|
@ -48,10 +52,21 @@ class MentionsModal extends React.PureComponent {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.fetchData();
|
this.fetchData();
|
||||||
|
this.unlistenHistory = this.context.router.history.listen((_, action) => {
|
||||||
|
if (action === 'PUSH') {
|
||||||
|
this.onClickClose(null, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickClose = () => {
|
componentWillUnmount() {
|
||||||
this.props.onClose('MENTIONS');
|
if (this.unlistenHistory) {
|
||||||
|
this.unlistenHistory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onClickClose = (_, noPop) => {
|
||||||
|
this.props.onClose('MENTIONS', noPop);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -62,6 +62,7 @@ export default class ModalRoot extends React.PureComponent {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
type: PropTypes.string,
|
type: PropTypes.string,
|
||||||
props: PropTypes.object,
|
props: PropTypes.object,
|
||||||
|
noPop: PropTypes.bool,
|
||||||
onClose: PropTypes.func.isRequired,
|
onClose: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -85,17 +86,17 @@ export default class ModalRoot extends React.PureComponent {
|
||||||
return <BundleModalError {...props} onClose={this.onClickClose} />;
|
return <BundleModalError {...props} onClose={this.onClickClose} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickClose = () => {
|
onClickClose = (_, noPop) => {
|
||||||
const { onClose, type } = this.props;
|
const { onClose, type } = this.props;
|
||||||
onClose(type);
|
onClose(type, noPop);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { type, props } = this.props;
|
const { type, props, noPop } = this.props;
|
||||||
const visible = !!type;
|
const visible = !!type;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Base onClose={this.onClickClose} type={type}>
|
<Base onClose={this.onClickClose} type={type} noPop={noPop}>
|
||||||
{visible && (
|
{visible && (
|
||||||
<BundleContainer fetchComponent={MODAL_COMPONENTS[type]} loading={this.renderLoading(type)} error={this.renderError} renderDelay={200}>
|
<BundleContainer fetchComponent={MODAL_COMPONENTS[type]} loading={this.renderLoading(type)} error={this.renderError} renderDelay={200}>
|
||||||
{(SpecificComponent) => <SpecificComponent {...props} onClose={this.onClickClose} />}
|
{(SpecificComponent) => <SpecificComponent {...props} onClose={this.onClickClose} />}
|
||||||
|
|
|
@ -29,6 +29,10 @@ export default @connect(mapStateToProps)
|
||||||
@injectIntl
|
@injectIntl
|
||||||
class ReactionsModal extends React.PureComponent {
|
class ReactionsModal extends React.PureComponent {
|
||||||
|
|
||||||
|
static contextTypes = {
|
||||||
|
router: PropTypes.object,
|
||||||
|
};
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
onClose: PropTypes.func.isRequired,
|
onClose: PropTypes.func.isRequired,
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
|
@ -52,10 +56,21 @@ class ReactionsModal extends React.PureComponent {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.fetchData();
|
this.fetchData();
|
||||||
|
this.unlistenHistory = this.context.router.history.listen((_, action) => {
|
||||||
|
if (action === 'PUSH') {
|
||||||
|
this.onClickClose(null, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickClose = () => {
|
componentWillUnmount() {
|
||||||
this.props.onClose('REACTIONS');
|
if (this.unlistenHistory) {
|
||||||
|
this.unlistenHistory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onClickClose = (_, noPop) => {
|
||||||
|
this.props.onClose('REACTIONS', noPop);
|
||||||
};
|
};
|
||||||
|
|
||||||
handleFilterChange = (reaction) => () => {
|
handleFilterChange = (reaction) => () => {
|
||||||
|
|
|
@ -24,6 +24,10 @@ export default @connect(mapStateToProps)
|
||||||
@injectIntl
|
@injectIntl
|
||||||
class ReblogsModal extends React.PureComponent {
|
class ReblogsModal extends React.PureComponent {
|
||||||
|
|
||||||
|
static contextTypes = {
|
||||||
|
router: PropTypes.object,
|
||||||
|
};
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
onClose: PropTypes.func.isRequired,
|
onClose: PropTypes.func.isRequired,
|
||||||
intl: PropTypes.object.isRequired,
|
intl: PropTypes.object.isRequired,
|
||||||
|
@ -42,10 +46,21 @@ class ReblogsModal extends React.PureComponent {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.fetchData();
|
this.fetchData();
|
||||||
|
this.unlistenHistory = this.context.router.history.listen((_, action) => {
|
||||||
|
if (action === 'PUSH') {
|
||||||
|
this.onClickClose(null, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onClickClose = () => {
|
componentWillUnmount() {
|
||||||
this.props.onClose('REBLOGS');
|
if (this.unlistenHistory) {
|
||||||
|
this.unlistenHistory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onClickClose = (_, noPop) => {
|
||||||
|
this.props.onClose('REBLOGS', noPop);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -6,15 +6,16 @@ import ModalRoot from '../components/modal_root';
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
type: state.get('modal').modalType,
|
type: state.get('modal').modalType,
|
||||||
props: state.get('modal').modalProps,
|
props: state.get('modal').modalProps,
|
||||||
|
noPop: state.get('modal').noPop,
|
||||||
});
|
});
|
||||||
|
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
onClose(optionalType) {
|
onClose(optionalType, noPop) {
|
||||||
if (optionalType === 'COMPOSE') {
|
if (optionalType === 'COMPOSE') {
|
||||||
dispatch(cancelReplyCompose());
|
dispatch(cancelReplyCompose());
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch(closeModal());
|
dispatch(closeModal(undefined, noPop));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ describe('modal reducer', () => {
|
||||||
expect(reducer(undefined, {})).toEqual({
|
expect(reducer(undefined, {})).toEqual({
|
||||||
modalType: null,
|
modalType: null,
|
||||||
modalProps: {},
|
modalProps: {},
|
||||||
|
noPop: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -13,6 +14,7 @@ describe('modal reducer', () => {
|
||||||
const state = {
|
const state = {
|
||||||
modalType: null,
|
modalType: null,
|
||||||
modalProps: {},
|
modalProps: {},
|
||||||
|
noPop: false,
|
||||||
};
|
};
|
||||||
const action = {
|
const action = {
|
||||||
type: MODAL_OPEN,
|
type: MODAL_OPEN,
|
||||||
|
@ -36,6 +38,7 @@ describe('modal reducer', () => {
|
||||||
expect(reducer(state, action)).toMatchObject({
|
expect(reducer(state, action)).toMatchObject({
|
||||||
modalType: null,
|
modalType: null,
|
||||||
modalProps: {},
|
modalProps: {},
|
||||||
|
noPop: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { MODAL_OPEN, MODAL_CLOSE } from '../actions/modal';
|
||||||
const initialState = {
|
const initialState = {
|
||||||
modalType: null,
|
modalType: null,
|
||||||
modalProps: {},
|
modalProps: {},
|
||||||
|
noPop: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function modal(state = initialState, action) {
|
export default function modal(state = initialState, action) {
|
||||||
|
@ -10,7 +11,12 @@ export default function modal(state = initialState, action) {
|
||||||
case MODAL_OPEN:
|
case MODAL_OPEN:
|
||||||
return { modalType: action.modalType, modalProps: action.modalProps };
|
return { modalType: action.modalType, modalProps: action.modalProps };
|
||||||
case MODAL_CLOSE:
|
case MODAL_CLOSE:
|
||||||
return (action.modalType === undefined || action.modalType === state.modalType) ? initialState : state;
|
return {
|
||||||
|
...(action.modalType === undefined || action.modalType === state.modalType)
|
||||||
|
? initialState
|
||||||
|
: state,
|
||||||
|
noPop: !!action.noPop,
|
||||||
|
};
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue