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/store.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/store.js')
-rw-r--r-- | src/features/todos/store.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/features/todos/store.js b/src/features/todos/store.js index c1d6a9049..af8519d9c 100644 --- a/src/features/todos/store.js +++ b/src/features/todos/store.js | |||
@@ -16,6 +16,8 @@ import { | |||
16 | import { IPC } from './constants'; | 16 | import { IPC } from './constants'; |
17 | import { state as delayAppState } from '../delayApp'; | 17 | import { state as delayAppState } from '../delayApp'; |
18 | 18 | ||
19 | import UserAgent from '../../models/UserAgent'; | ||
20 | |||
19 | const debug = require('debug')('Ferdi:feature:todos:store'); | 21 | const debug = require('debug')('Ferdi:feature:todos:store'); |
20 | 22 | ||
21 | export default class TodoStore extends FeatureStore { | 23 | export default class TodoStore extends FeatureStore { |
@@ -25,6 +27,8 @@ export default class TodoStore extends FeatureStore { | |||
25 | 27 | ||
26 | @observable webview = null; | 28 | @observable webview = null; |
27 | 29 | ||
30 | @observable userAgentModel = new UserAgent(); | ||
31 | |||
28 | isInitialized = false; | 32 | isInitialized = false; |
29 | 33 | ||
30 | @computed get width() { | 34 | @computed get width() { |
@@ -51,6 +55,10 @@ export default class TodoStore extends FeatureStore { | |||
51 | return localStorage.getItem('todos') || {}; | 55 | return localStorage.getItem('todos') || {}; |
52 | } | 56 | } |
53 | 57 | ||
58 | @computed get userAgent() { | ||
59 | return this.userAgentModel.userAgent; | ||
60 | } | ||
61 | |||
54 | // ========== PUBLIC API ========= // | 62 | // ========== PUBLIC API ========= // |
55 | 63 | ||
56 | @action start(stores, actions) { | 64 | @action start(stores, actions) { |
@@ -123,7 +131,10 @@ export default class TodoStore extends FeatureStore { | |||
123 | 131 | ||
124 | @action _setTodosWebview = ({ webview }) => { | 132 | @action _setTodosWebview = ({ webview }) => { |
125 | debug('_setTodosWebview', webview); | 133 | debug('_setTodosWebview', webview); |
126 | this.webview = webview; | 134 | if (this.webview !== webview) { |
135 | this.webview = webview; | ||
136 | this.userAgentModel.setWebviewReference(webview); | ||
137 | } | ||
127 | }; | 138 | }; |
128 | 139 | ||
129 | @action _handleHostMessage = (message) => { | 140 | @action _handleHostMessage = (message) => { |