diff options
author | 2021-09-14 19:58:52 +0200 | |
---|---|---|
committer | 2021-09-14 19:58:52 +0200 | |
commit | 95df3522a15631abc51a4295cae0ea401a8d4e1e (patch) | |
tree | e5eb0f368c947683f01458e912f21756fb0d99cb /src/models/UserAgent.js | |
parent | docs: add sad270 as a contributor for bug, userTesting [skip ci] (#1941) (diff) | |
download | ferdium-app-95df3522a15631abc51a4295cae0ea401a8d4e1e.tar.gz ferdium-app-95df3522a15631abc51a4295cae0ea401a8d4e1e.tar.zst ferdium-app-95df3522a15631abc51a4295cae0ea401a8d4e1e.zip |
feat: add eslint-plugin-unicorn (#1936)
Diffstat (limited to 'src/models/UserAgent.js')
-rw-r--r-- | src/models/UserAgent.js | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/models/UserAgent.js b/src/models/UserAgent.js index 930ae19ef..8ec274aa5 100644 --- a/src/models/UserAgent.js +++ b/src/models/UserAgent.js | |||
@@ -1,9 +1,4 @@ | |||
1 | import { | 1 | import { action, computed, observe, observable } from 'mobx'; |
2 | action, | ||
3 | computed, | ||
4 | observe, | ||
5 | observable, | ||
6 | } from 'mobx'; | ||
7 | 2 | ||
8 | import defaultUserAgent from '../helpers/userAgent-helpers'; | 3 | import defaultUserAgent from '../helpers/userAgent-helpers'; |
9 | 4 | ||
@@ -27,7 +22,7 @@ export default class UserAgent { | |||
27 | this.getUserAgent = overrideUserAgent; | 22 | this.getUserAgent = overrideUserAgent; |
28 | } | 23 | } |
29 | 24 | ||
30 | observe(this, 'webview', (change) => { | 25 | observe(this, 'webview', change => { |
31 | const { oldValue, newValue } = change; | 26 | const { oldValue, newValue } = change; |
32 | if (oldValue !== null) { | 27 | if (oldValue !== null) { |
33 | this._removeWebviewEvents(oldValue); | 28 | this._removeWebviewEvents(oldValue); |
@@ -64,11 +59,13 @@ export default class UserAgent { | |||
64 | 59 | ||
65 | @computed get userAgentWithoutChromeVersion() { | 60 | @computed get userAgentWithoutChromeVersion() { |
66 | const withChrome = this.userAgentWithChromeVersion; | 61 | const withChrome = this.userAgentWithChromeVersion; |
67 | return withChrome.replace(/Chrome\/[0-9.]+/, 'Chrome'); | 62 | return withChrome.replace(/Chrome\/[\d.]+/, 'Chrome'); |
68 | } | 63 | } |
69 | 64 | ||
70 | @computed get userAgent() { | 65 | @computed get userAgent() { |
71 | return this.chromelessUserAgent ? this.userAgentWithoutChromeVersion : this.userAgentWithChromeVersion; | 66 | return this.chromelessUserAgent |
67 | ? this.userAgentWithoutChromeVersion | ||
68 | : this.userAgentWithChromeVersion; | ||
72 | } | 69 | } |
73 | 70 | ||
74 | @action setWebviewReference(webview) { | 71 | @action setWebviewReference(webview) { |
@@ -95,10 +92,10 @@ export default class UserAgent { | |||
95 | _addWebviewEvents(webview) { | 92 | _addWebviewEvents(webview) { |
96 | debug('Adding event handlers'); | 93 | debug('Adding event handlers'); |
97 | 94 | ||
98 | this._willNavigateListener = (event) => this._handleNavigate(event.url, true); | 95 | this._willNavigateListener = event => this._handleNavigate(event.url, true); |
99 | webview.addEventListener('will-navigate', this._willNavigateListener); | 96 | webview.addEventListener('will-navigate', this._willNavigateListener); |
100 | 97 | ||
101 | this._didNavigateListener = (event) => this._handleNavigate(event.url); | 98 | this._didNavigateListener = event => this._handleNavigate(event.url); |
102 | webview.addEventListener('did-navigate', this._didNavigateListener); | 99 | webview.addEventListener('did-navigate', this._didNavigateListener); |
103 | } | 100 | } |
104 | 101 | ||