diff options
Diffstat (limited to 'src/features/webControls')
-rw-r--r-- | src/features/webControls/containers/WebControlsScreen.jsx (renamed from src/features/webControls/containers/WebControlsScreen.js) | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/features/webControls/containers/WebControlsScreen.js b/src/features/webControls/containers/WebControlsScreen.jsx index e5567eec5..25e14060d 100644 --- a/src/features/webControls/containers/WebControlsScreen.js +++ b/src/features/webControls/containers/WebControlsScreen.jsx | |||
@@ -2,7 +2,7 @@ import { Component } from 'react'; | |||
2 | import { observer, inject } from 'mobx-react'; | 2 | import { observer, inject } from 'mobx-react'; |
3 | import PropTypes from 'prop-types'; | 3 | import PropTypes from 'prop-types'; |
4 | 4 | ||
5 | import { autorun, makeObservable, observable } from 'mobx'; | 5 | import { autorun, action, makeObservable, observable } from 'mobx'; |
6 | import WebControls from '../components/WebControls'; | 6 | import WebControls from '../components/WebControls'; |
7 | import ServicesStore from '../../../stores/ServicesStore'; | 7 | import ServicesStore from '../../../stores/ServicesStore'; |
8 | import Service from '../../../models/Service'; | 8 | import Service from '../../../models/Service'; |
@@ -27,6 +27,16 @@ class WebControlsScreen extends Component { | |||
27 | 27 | ||
28 | autorunDisposer = null; | 28 | autorunDisposer = null; |
29 | 29 | ||
30 | @action _setUrl(value) { | ||
31 | this.url = value; | ||
32 | } | ||
33 | |||
34 | @action _setUrlAndHistory(value) { | ||
35 | this._setUrl(value); | ||
36 | this.canGoBack = this.webview.canGoBack(); | ||
37 | this.canGoForward = this.webview.canGoForward(); | ||
38 | } | ||
39 | |||
30 | constructor(props) { | 40 | constructor(props) { |
31 | super(props); | 41 | super(props); |
32 | 42 | ||
@@ -39,15 +49,13 @@ class WebControlsScreen extends Component { | |||
39 | this.autorunDisposer = autorun(() => { | 49 | this.autorunDisposer = autorun(() => { |
40 | if (service.isAttached) { | 50 | if (service.isAttached) { |
41 | this.webview = service.webview; | 51 | this.webview = service.webview; |
42 | this.url = this.webview.getURL(); | 52 | this._setUrl(this.webview.getURL()); |
43 | 53 | ||
44 | for (const event of URL_EVENTS) { | 54 | for (const event of URL_EVENTS) { |
45 | this.webview.addEventListener(event, e => { | 55 | this.webview.addEventListener(event, e => { |
46 | if (!e.isMainFrame) return; | 56 | if (!e.isMainFrame) return; |
47 | 57 | ||
48 | this.url = e.url; | 58 | this._setUrlAndHistory(e.url); |
49 | this.canGoBack = this.webview.canGoBack(); | ||
50 | this.canGoForward = this.webview.canGoForward(); | ||
51 | }); | 59 | }); |
52 | } | 60 | } |
53 | } | 61 | } |
@@ -101,7 +109,7 @@ class WebControlsScreen extends Component { | |||
101 | } | 109 | } |
102 | 110 | ||
103 | this.webview.loadURL(url); | 111 | this.webview.loadURL(url); |
104 | this.url = url; | 112 | this._setUrl(url); |
105 | } | 113 | } |
106 | 114 | ||
107 | openInBrowser() { | 115 | openInBrowser() { |