summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/editor/editor.gate.js
blob: 968680f2215180817037e40ab8162baddb27e792 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React, { Component } from 'react'

import { Loader } from 'app/common'

import actions from 'app/actions'

export default class EditorGate extends Component {
  constructor(props) {
    super(props)
    this.load()
  }

  componentDidUpdate(prevProps) {
    if (this.props.episode_id !== prevProps.episode_id) {
      this.load()
    }
  }

  load() {
    this.props.episode_id && actions.site.loadEpisode()
  }

  render() {
    if (this.props.logged_in) {
      return this.props.children
    }
    return (
      <Loader />
    )
  }
}