aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/todos/containers/TodosScreen.js
blob: 2b81bd7287c35ee600f753f51116af417e53da02 (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
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 { TODOS_MIN_WIDTH, todosStore } from '..';
import { todoActions } from '../actions';

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

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

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

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

export default TodosScreen;