next: { id: 'lightbox.next', defaultMessage: 'Next' },
});
+const previewState = 'previewMediaModal';
+
@injectIntl
export default class MediaModal extends ImmutablePureComponent {
intl: PropTypes.object.isRequired,
};
+ static contextTypes = {
+ router: PropTypes.object,
+ };
+
state = {
index: null,
navigationHidden: false,
componentDidMount () {
window.addEventListener('keyup', this.handleKeyUp, false);
+ const history = this.context.router.history;
+ history.push(history.location.pathname, previewState);
+ this.unlistenHistory = history.listen(() => {
+ this.props.onClose();
+ });
}
componentWillUnmount () {
window.removeEventListener('keyup', this.handleKeyUp);
+ this.unlistenHistory();
+
+ if (this.context.router.history.location.state === previewState) {
+ this.context.router.history.goBack();
+ }
}
getIndex () {