aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/todos/components/TodosWebview.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/features/todos/components/TodosWebview.js')
-rw-r--r--src/features/todos/components/TodosWebview.js20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/features/todos/components/TodosWebview.js b/src/features/todos/components/TodosWebview.js
index 1d99b9388..1f4730094 100644
--- a/src/features/todos/components/TodosWebview.js
+++ b/src/features/todos/components/TodosWebview.js
@@ -35,6 +35,8 @@ class TodosWebview extends Component {
35 static propTypes = { 35 static propTypes = {
36 classes: PropTypes.object.isRequired, 36 classes: PropTypes.object.isRequired,
37 authToken: PropTypes.string.isRequired, 37 authToken: PropTypes.string.isRequired,
38 handleClientMessage: PropTypes.func.isRequired,
39 setTodosWebview: PropTypes.func.isRequired,
38 resize: PropTypes.func.isRequired, 40 resize: PropTypes.func.isRequired,
39 width: PropTypes.number.isRequired, 41 width: PropTypes.number.isRequired,
40 minWidth: PropTypes.number.isRequired, 42 minWidth: PropTypes.number.isRequired,
@@ -43,7 +45,7 @@ class TodosWebview extends Component {
43 state = { 45 state = {
44 isDragging: false, 46 isDragging: false,
45 width: 300, 47 width: 300,
46 } 48 };
47 49
48 componentWillMount() { 50 componentWillMount() {
49 const { width } = this.props; 51 const { width } = this.props;
@@ -65,7 +67,7 @@ class TodosWebview extends Component {
65 initialPos: event.clientX, 67 initialPos: event.clientX,
66 delta: 0, 68 delta: 0,
67 }); 69 });
68 } 70 };
69 71
70 resizePanel(e) { 72 resizePanel(e) {
71 const { minWidth } = this.props; 73 const { minWidth } = this.props;
@@ -113,10 +115,15 @@ class TodosWebview extends Component {
113 } 115 }
114 } 116 }
115 117
118 startListeningToIpcMessages() {
119 const { handleClientMessage } = this.props;
120 if (!this.webview) return;
121 this.webview.addEventListener('ipc-message', e => handleClientMessage(e.args[0]));
122 }
123
116 render() { 124 render() {
117 const { authToken, classes } = this.props; 125 const { authToken, classes } = this.props;
118 const { width, delta, isDragging } = this.state; 126 const { width, delta, isDragging } = this.state;
119
120 return ( 127 return (
121 <> 128 <>
122 <div 129 <div
@@ -138,6 +145,13 @@ class TodosWebview extends Component {
138 )} 145 )}
139 <Webview 146 <Webview
140 className={classes.webview} 147 className={classes.webview}
148 onDidAttach={() => {
149 this.props.setTodosWebview(this.webview);
150 this.startListeningToIpcMessages();
151 }}
152 partition="persist:todos"
153 preload="./features/todos/preload.js"
154 ref={(webview) => { this.webview = webview ? webview.view : null; }}
141 src={`${environment.TODOS_FRONTEND}?authToken=${authToken}`} 155 src={`${environment.TODOS_FRONTEND}?authToken=${authToken}`}
142 /> 156 />
143 </div> 157 </div>