mirror of
https://github.com/kikobar/mastodon.git
synced 2024-11-18 21:27:41 +00:00
Check if router is injected in media modal (#7941)
This commit is contained in:
parent
9dc413b025
commit
f3af1a96a8
|
@ -67,19 +67,23 @@ export default class MediaModal extends ImmutablePureComponent {
|
|||
|
||||
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();
|
||||
});
|
||||
if (this.context.router) {
|
||||
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) {
|
||||
this.unlistenHistory();
|
||||
|
||||
if (this.context.router.history.location.state === previewState) {
|
||||
this.context.router.history.goBack();
|
||||
if (this.context.router.history.location.state === previewState) {
|
||||
this.context.router.history.goBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue