import React, { Component } from 'react' import { connect } from 'react-redux' import { Loader } from 'app/common' import actions from 'app/actions' class EditorGate extends Component { constructor(props) { super(props) this.load() } componentDidMount() { this.load() } componentDidUpdate(prevProps) { if ( this.props.episode_id !== prevProps.episode_id || this.props.episode.lookup !== prevProps.episode.lookup ) { this.load() } } load() { if (!this.props.episode.lookup) return if (!this.props.episode_id) return const episode = this.props.episode.lookup[this.props.episode_id] actions.site.loadEpisode(episode) } render() { if (parseInt(this.props.episode_id) === parseInt(this.props.currentEpisodeId)) { return this.props.children } return (