aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/webControls
diff options
context:
space:
mode:
authorLibravatar André Oliveira <37463445+SpecialAro@users.noreply.github.com>2022-08-04 00:12:03 +0100
committerLibravatar GitHub <noreply@github.com>2022-08-03 23:12:03 +0000
commitc2509e860752e23812bb408e331c02c918aadd54 (patch)
treeb855163ad1bddaaa19c47a9cea2713c6899ea1a5 /src/features/webControls
parentRevert to older working version of 'macos-notification-state' (diff)
downloadferdium-app-c2509e860752e23812bb408e331c02c918aadd54.tar.gz
ferdium-app-c2509e860752e23812bb408e331c02c918aadd54.tar.zst
ferdium-app-c2509e860752e23812bb408e331c02c918aadd54.zip
chore: change values inside mobx actions to fix console warnings (#532)
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';
2import { observer, inject } from 'mobx-react'; 2import { observer, inject } from 'mobx-react';
3import PropTypes from 'prop-types'; 3import PropTypes from 'prop-types';
4 4
5import { autorun, makeObservable, observable } from 'mobx'; 5import { autorun, action, makeObservable, observable } from 'mobx';
6import WebControls from '../components/WebControls'; 6import WebControls from '../components/WebControls';
7import ServicesStore from '../../../stores/ServicesStore'; 7import ServicesStore from '../../../stores/ServicesStore';
8import Service from '../../../models/Service'; 8import 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() {