diff options
author | Kristóf Marussy <kristof@marussy.com> | 2021-06-03 19:01:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-03 19:01:01 +0200 |
commit | 2ad39ffb1cb0d0e5f79d6948f798ca79ed73c76c (patch) | |
tree | dcb679119cf4963126a3520b7c62ae4b032e0225 /src/features/todos/components/TodosWebview.js | |
parent | Upgraded electron to '13.1.0'. (diff) | |
download | ferdium-app-2ad39ffb1cb0d0e5f79d6948f798ca79ed73c76c.tar.gz ferdium-app-2ad39ffb1cb0d0e5f79d6948f798ca79ed73c76c.tar.zst ferdium-app-2ad39ffb1cb0d0e5f79d6948f798ca79ed73c76c.zip |
* Expose Chrome version to todos webview (fix #1211)
The TickTick todo service fails to load if the Chrome version number
does not appear in the User-Agent string. However, login to Google Tasks
is prevented by the same.
We adopt the "chromeless" User-Agent logic from the service webview,
which selectively exposes the Chrome version everywhere except the
Google login screen. The common logic was moved into the
userAgent-helpers module.
* Refactor user agent switching
* "Chromeless" user agent switching is extracted into a separate model
* Both the service and the todos webview uses the same model
Diffstat (limited to 'src/features/todos/components/TodosWebview.js')
-rw-r--r-- | src/features/todos/components/TodosWebview.js | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/features/todos/components/TodosWebview.js b/src/features/todos/components/TodosWebview.js index 18a900e8a..634ec4caa 100644 --- a/src/features/todos/components/TodosWebview.js +++ b/src/features/todos/components/TodosWebview.js | |||
@@ -14,8 +14,6 @@ import Appear from '../../../components/ui/effects/Appear'; | |||
14 | import UpgradeButton from '../../../components/ui/UpgradeButton'; | 14 | import UpgradeButton from '../../../components/ui/UpgradeButton'; |
15 | import { TODOS_PARTITION_ID } from '..'; | 15 | import { TODOS_PARTITION_ID } from '..'; |
16 | 16 | ||
17 | import userAgent from '../../../helpers/userAgent-helpers'; | ||
18 | |||
19 | // NOTE: https://stackoverflow.com/questions/5717093/check-if-a-javascript-string-is-a-url | 17 | // NOTE: https://stackoverflow.com/questions/5717093/check-if-a-javascript-string-is-a-url |
20 | function validURL(str) { | 18 | function validURL(str) { |
21 | let url; | 19 | let url; |
@@ -112,6 +110,7 @@ class TodosWebview extends Component { | |||
112 | resize: PropTypes.func.isRequired, | 110 | resize: PropTypes.func.isRequired, |
113 | width: PropTypes.number.isRequired, | 111 | width: PropTypes.number.isRequired, |
114 | minWidth: PropTypes.number.isRequired, | 112 | minWidth: PropTypes.number.isRequired, |
113 | userAgent: PropTypes.string.isRequired, | ||
115 | isTodosIncludedInCurrentPlan: PropTypes.bool.isRequired, | 114 | isTodosIncludedInCurrentPlan: PropTypes.bool.isRequired, |
116 | stores: PropTypes.shape({ | 115 | stores: PropTypes.shape({ |
117 | settings: PropTypes.instanceOf(SettingsStore).isRequired, | 116 | settings: PropTypes.instanceOf(SettingsStore).isRequired, |
@@ -139,11 +138,6 @@ class TodosWebview extends Component { | |||
139 | this.node.addEventListener('mousemove', this.resizePanel.bind(this)); | 138 | this.node.addEventListener('mousemove', this.resizePanel.bind(this)); |
140 | this.node.addEventListener('mouseup', this.stopResize.bind(this)); | 139 | this.node.addEventListener('mouseup', this.stopResize.bind(this)); |
141 | this.node.addEventListener('mouseleave', this.stopResize.bind(this)); | 140 | this.node.addEventListener('mouseleave', this.stopResize.bind(this)); |
142 | |||
143 | const webViewInstance = this; | ||
144 | this.webview.addEventListener('dom-ready', () => { | ||
145 | webViewInstance.webview.setUserAgent(userAgent(true)); | ||
146 | }); | ||
147 | } | 141 | } |
148 | 142 | ||
149 | startResize = (event) => { | 143 | startResize = (event) => { |
@@ -214,6 +208,7 @@ class TodosWebview extends Component { | |||
214 | classes, | 208 | classes, |
215 | isTodosServiceActive, | 209 | isTodosServiceActive, |
216 | isVisible, | 210 | isVisible, |
211 | userAgent, | ||
217 | isTodosIncludedInCurrentPlan, | 212 | isTodosIncludedInCurrentPlan, |
218 | stores, | 213 | stores, |
219 | } = this.props; | 214 | } = this.props; |
@@ -275,6 +270,7 @@ class TodosWebview extends Component { | |||
275 | partition={TODOS_PARTITION_ID} | 270 | partition={TODOS_PARTITION_ID} |
276 | preload="./features/todos/preload.js" | 271 | preload="./features/todos/preload.js" |
277 | ref={(webview) => { this.webview = webview ? webview.view : null; }} | 272 | ref={(webview) => { this.webview = webview ? webview.view : null; }} |
273 | useragent={userAgent} | ||
278 | src={todoUrl} | 274 | src={todoUrl} |
279 | /> | 275 | /> |
280 | ) | 276 | ) |