diff options
author | Stefan Malzner <stefan@adlk.io> | 2018-12-08 17:08:58 +0100 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2018-12-08 17:08:58 +0100 |
commit | a5e7171402eb27a4527a238d186c88ac03f8ffd7 (patch) | |
tree | 897708a2cfc88569c04f4896bacf2c9d390c7b39 /src/models | |
parent | Add service spellchecker language strings (diff) | |
download | ferdium-app-a5e7171402eb27a4527a238d186c88ac03f8ffd7.tar.gz ferdium-app-a5e7171402eb27a4527a238d186c88ac03f8ffd7.tar.zst ferdium-app-a5e7171402eb27a4527a238d186c88ac03f8ffd7.zip |
feat(Service): Add error screen for services that failed to load
Diffstat (limited to 'src/models')
-rw-r--r-- | src/models/Service.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/models/Service.js b/src/models/Service.js index deeb544d1..7ba9aa396 100644 --- a/src/models/Service.js +++ b/src/models/Service.js | |||
@@ -2,6 +2,8 @@ import { computed, observable, autorun } from 'mobx'; | |||
2 | import path from 'path'; | 2 | import path from 'path'; |
3 | import normalizeUrl from 'normalize-url'; | 3 | import normalizeUrl from 'normalize-url'; |
4 | 4 | ||
5 | const debug = require('debug')('Franz:Service'); | ||
6 | |||
5 | export default class Service { | 7 | export default class Service { |
6 | id = ''; | 8 | id = ''; |
7 | recipe = ''; | 9 | recipe = ''; |
@@ -31,6 +33,11 @@ export default class Service { | |||
31 | @observable isDarkModeEnabled = false; | 33 | @observable isDarkModeEnabled = false; |
32 | @observable spellcheckerLanguage = null; | 34 | @observable spellcheckerLanguage = null; |
33 | 35 | ||
36 | // @observable isFirstNavigation = true; | ||
37 | @observable isLoading = true; | ||
38 | @observable isError = false; | ||
39 | @observable errorMessage = ''; | ||
40 | |||
34 | constructor(data, recipe) { | 41 | constructor(data, recipe) { |
35 | if (!data) { | 42 | if (!data) { |
36 | console.error('Service config not valid'); | 43 | console.error('Service config not valid'); |
@@ -150,9 +157,25 @@ export default class Service { | |||
150 | 157 | ||
151 | this.webview.addEventListener('did-start-loading', () => { | 158 | this.webview.addEventListener('did-start-loading', () => { |
152 | this.hasCrashed = false; | 159 | this.hasCrashed = false; |
160 | this.isLoading = true; | ||
161 | this.isError = false; | ||
162 | }); | ||
163 | |||
164 | this.webview.addEventListener('did-stop-loading', () => { | ||
165 | this.isLoading = false; | ||
166 | }); | ||
167 | |||
168 | this.webview.addEventListener('did-fail-load', (event) => { | ||
169 | debug('Service failed to load', this.name, event); | ||
170 | if (event.isMainFrame) { | ||
171 | this.isError = true; | ||
172 | this.errorMessage = event.errorDescription; | ||
173 | this.isLoading = false; | ||
174 | } | ||
153 | }); | 175 | }); |
154 | 176 | ||
155 | this.webview.addEventListener('crashed', () => { | 177 | this.webview.addEventListener('crashed', () => { |
178 | debug('Service crashed', this.name); | ||
156 | this.hasCrashed = true; | 179 | this.hasCrashed = true; |
157 | }); | 180 | }); |
158 | } | 181 | } |