aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/todos/containers/TodosScreen.tsx
blob: 29ecd5a0e961d344b86608559ccb06c3c4fa59f9 (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
49
import { inject, observer } from 'mobx-react';
import { Component, type ReactElement } from 'react';
import { todosStore } from '..';
import ErrorBoundary from '../../../components/util/ErrorBoundary';
import { TODOS_MIN_WIDTH } from '../../../config';
import type { RealStores } from '../../../stores';
import { todoActions } from '../actions';
import TodosWebview from '../components/TodosWebview';

interface IProps {
  stores?: RealStores;
}

@inject('stores', 'actions')
@observer
class TodosScreen extends Component<IProps> {
  render(): ReactElement | null {
    const showTodoScreen =
      !todosStore ||
      !todosStore.isFeatureActive ||
      todosStore.isTodosPanelForceHidden;

    if (showTodoScreen) {
      return null;
    }

    return (
      <ErrorBoundary>
        <TodosWebview
          isTodosServiceActive={
            this.props.stores!.services.isTodosServiceActive || false
          }
          isVisible={todosStore.isTodosPanelVisible}
          // togglePanel={todoActions.toggleTodosPanel} // TODO: [TECH DEBT][PROP NOT USED IN COMPONENT] check it later
          handleClientMessage={todoActions.handleClientMessage}
          setTodosWebview={webview => todoActions.setTodosWebview(webview)}
          width={todosStore.width}
          minWidth={TODOS_MIN_WIDTH}
          resize={width => todoActions.resize(width)}
          userAgent={todosStore.userAgent}
          todoUrl={todosStore.todoUrl}
          isTodoUrlValid={todosStore.isTodoUrlValid}
        />
      </ErrorBoundary>
    );
  }
}

export default TodosScreen;