aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/todos/containers/TodosScreen.js
blob: 5b7c4531b807752a249d1d70b68aaa379164067e (plain) (blame)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React, { Component } from 'react';
import { inject, observer } from 'mobx-react';
import PropTypes from 'prop-types';

import TodosWebview from '../components/TodosWebview';
import ErrorBoundary from '../../../components/util/ErrorBoundary';
import UserStore from '../../../stores/UserStore';
import TodoStore from '../store';
import { TODOS_MIN_WIDTH } from '..';

@inject('stores', 'actions') @observer
class TodosScreen extends Component {
  static propTypes = {
    stores: PropTypes.shape({
      user: PropTypes.instanceOf(UserStore).isRequired,
      todos: PropTypes.instanceOf(TodoStore).isRequired,
    }).isRequired,
    actions: PropTypes.shape({
      todos: PropTypes.shape({
        resize: PropTypes.func.isRequired,
        handleIPCMessage: PropTypes.func.isRequired,
      }),
    }).isRequired,
  };

  render() {
    const { stores, actions } = this.props;

    if (!stores.todos || !stores.todos.isFeatureActive) {
      return null;
    }

    return (
      <ErrorBoundary>
        <TodosWebview
          authToken={stores.user.authToken}
          handleClientMessage={actions.todos.handleClientMessage}
          setTodosWebview={webview => actions.todos.setTodosWebview({ webview })}
          width={stores.todos.width}
          minWidth={TODOS_MIN_WIDTH}
          resize={width => actions.todos.resize({ width })}
        />
      </ErrorBoundary>
    );
  }
}

export default TodosScreen;