diff options
author | 2021-02-08 10:34:45 +0100 | |
---|---|---|
committer | 2021-02-08 10:34:45 +0100 | |
commit | 035002ceedf78d5ec73eabc0df7f06139939b967 (patch) | |
tree | 1c0d1e9531bae05fb65d70b9ea25baf404b74fe1 /src/features/todos/store.js | |
parent | docs: add k0staa as a contributor (#1193) (diff) | |
download | ferdium-app-035002ceedf78d5ec73eabc0df7f06139939b967.tar.gz ferdium-app-035002ceedf78d5ec73eabc0df7f06139939b967.tar.zst ferdium-app-035002ceedf78d5ec73eabc0df7f06139939b967.zip |
Synchronize with Franz 5.6.0 (#1033)
Co-authored-by: FranzBot <i18n@meetfranz.com>
Co-authored-by: vantezzen <hello@vantezzen.io>
Co-authored-by: Makazzz <makazzzpro@live.ca>
Co-authored-by: Stefan Malzner <stefan@adlk.io>
Co-authored-by: Amine Mouafik <amine@mouafik.fr>
Diffstat (limited to 'src/features/todos/store.js')
-rw-r--r-- | src/features/todos/store.js | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/src/features/todos/store.js b/src/features/todos/store.js index a05203a04..c1d6a9049 100644 --- a/src/features/todos/store.js +++ b/src/features/todos/store.js | |||
@@ -23,7 +23,9 @@ export default class TodoStore extends FeatureStore { | |||
23 | 23 | ||
24 | @observable isFeatureActive = false; | 24 | @observable isFeatureActive = false; |
25 | 25 | ||
26 | webview = null; | 26 | @observable webview = null; |
27 | |||
28 | isInitialized = false; | ||
27 | 29 | ||
28 | @computed get width() { | 30 | @computed get width() { |
29 | const width = this.settings.width || DEFAULT_TODOS_WIDTH; | 31 | const width = this.settings.width || DEFAULT_TODOS_WIDTH; |
@@ -65,6 +67,8 @@ export default class TodoStore extends FeatureStore { | |||
65 | [todoActions.handleHostMessage, this._handleHostMessage], | 67 | [todoActions.handleHostMessage, this._handleHostMessage], |
66 | [todoActions.handleClientMessage, this._handleClientMessage], | 68 | [todoActions.handleClientMessage, this._handleClientMessage], |
67 | [todoActions.toggleTodosFeatureVisibility, this._toggleTodosFeatureVisibility], | 69 | [todoActions.toggleTodosFeatureVisibility, this._toggleTodosFeatureVisibility], |
70 | [todoActions.openDevTools, this._openDevTools], | ||
71 | [todoActions.reload, this._reload], | ||
68 | ])); | 72 | ])); |
69 | 73 | ||
70 | // REACTIONS | 74 | // REACTIONS |
@@ -129,16 +133,28 @@ export default class TodoStore extends FeatureStore { | |||
129 | } | 133 | } |
130 | }; | 134 | }; |
131 | 135 | ||
132 | @action _handleClientMessage = (message) => { | 136 | @action _handleClientMessage = ({ channel, message = {} }) => { |
133 | debug('_handleClientMessage', message); | 137 | debug('_handleClientMessage', channel, message); |
134 | switch (message.action) { | 138 | switch (message.action) { |
135 | case 'todos:initialized': this._onTodosClientInitialized(); break; | 139 | case 'todos:initialized': this._onTodosClientInitialized(); break; |
136 | case 'todos:goToService': this._goToService(message.data); break; | 140 | case 'todos:goToService': this._goToService(message.data); break; |
137 | default: | 141 | default: |
138 | debug('Unknown client message reiceived', message); | 142 | debug('Other message received', channel, message); |
143 | console.log('this.stores.services.isTodosServiceAdded', this.stores.services.isTodosServiceAdded); | ||
144 | if (this.stores.services.isTodosServiceAdded) { | ||
145 | this.actions.service.handleIPCMessage({ | ||
146 | serviceId: this.stores.services.isTodosServiceAdded.id, | ||
147 | channel, | ||
148 | args: message, | ||
149 | }); | ||
150 | } | ||
139 | } | 151 | } |
140 | }; | 152 | }; |
141 | 153 | ||
154 | _handleNewWindowEvent = ({ url }) => { | ||
155 | this.actions.app.openExternalUrl({ url }); | ||
156 | } | ||
157 | |||
142 | @action _toggleTodosFeatureVisibility = () => { | 158 | @action _toggleTodosFeatureVisibility = () => { |
143 | debug('_toggleTodosFeatureVisibility'); | 159 | debug('_toggleTodosFeatureVisibility'); |
144 | 160 | ||
@@ -147,14 +163,28 @@ export default class TodoStore extends FeatureStore { | |||
147 | }); | 163 | }); |
148 | }; | 164 | }; |
149 | 165 | ||
166 | _openDevTools = () => { | ||
167 | debug('_openDevTools'); | ||
168 | |||
169 | const webview = document.querySelector('#todos-panel webview'); | ||
170 | if (webview) webview.openDevTools(); | ||
171 | } | ||
172 | |||
173 | _reload = () => { | ||
174 | debug('_reload'); | ||
175 | |||
176 | const webview = document.querySelector('#todos-panel webview'); | ||
177 | if (webview) webview.reload(); | ||
178 | } | ||
179 | |||
150 | // Todos client message handlers | 180 | // Todos client message handlers |
151 | 181 | ||
152 | _onTodosClientInitialized = () => { | 182 | _onTodosClientInitialized = async () => { |
153 | const { authToken } = this.stores.user; | 183 | const { authToken } = this.stores.user; |
154 | const { isDarkThemeActive } = this.stores.ui; | 184 | const { isDarkThemeActive } = this.stores.ui; |
155 | const { locale } = this.stores.app; | 185 | const { locale } = this.stores.app; |
156 | if (!this.webview) return; | 186 | if (!this.webview) return; |
157 | this.webview.send(IPC.TODOS_HOST_CHANNEL, { | 187 | await this.webview.send(IPC.TODOS_HOST_CHANNEL, { |
158 | action: 'todos:configure', | 188 | action: 'todos:configure', |
159 | data: { | 189 | data: { |
160 | authToken, | 190 | authToken, |
@@ -163,9 +193,11 @@ export default class TodoStore extends FeatureStore { | |||
163 | }, | 193 | }, |
164 | }); | 194 | }); |
165 | 195 | ||
166 | this.webview.addEventListener('new-window', ({ url }) => { | 196 | if (!this.isInitialized) { |
167 | this.actions.app.openExternalUrl({ url }); | 197 | this.webview.addEventListener('new-window', this._handleNewWindowEvent); |
168 | }); | 198 | |
199 | this.isInitialized = true; | ||
200 | } | ||
169 | }; | 201 | }; |
170 | 202 | ||
171 | _goToService = ({ url, serviceId }) => { | 203 | _goToService = ({ url, serviceId }) => { |