diff options
author | Stefan Malzner <stefan@adlk.io> | 2017-11-23 16:17:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-23 16:17:34 +0100 |
commit | abca425e4a7b63be93132067bc335e8b6b39c2b2 (patch) | |
tree | e386f3e5d4c1c1caff19e3555e7ed1ce93e625f6 /src/models/Service.js | |
parent | replace typeform (diff) | |
parent | Add windows notification fix to changelog (diff) | |
download | ferdium-app-abca425e4a7b63be93132067bc335e8b6b39c2b2.tar.gz ferdium-app-abca425e4a7b63be93132067bc335e8b6b39c2b2.tar.zst ferdium-app-abca425e4a7b63be93132067bc335e8b6b39c2b2.zip |
Merge pull request #330 from meetfranz/developv5.0.0-beta.14
Beta 14
Diffstat (limited to 'src/models/Service.js')
-rw-r--r-- | src/models/Service.js | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/models/Service.js b/src/models/Service.js index 484252e7c..958e4b11e 100644 --- a/src/models/Service.js +++ b/src/models/Service.js | |||
@@ -1,4 +1,4 @@ | |||
1 | import { computed, observable } from 'mobx'; | 1 | 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 | ||
@@ -18,11 +18,13 @@ export default class Service { | |||
18 | 18 | ||
19 | @observable order = 99; | 19 | @observable order = 99; |
20 | @observable isEnabled = true; | 20 | @observable isEnabled = true; |
21 | @observable isMuted = false; | ||
21 | @observable team = ''; | 22 | @observable team = ''; |
22 | @observable customUrl = ''; | 23 | @observable customUrl = ''; |
23 | @observable isNotificationEnabled = true; | 24 | @observable isNotificationEnabled = true; |
24 | @observable isIndirectMessageBadgeEnabled = true; | 25 | @observable isIndirectMessageBadgeEnabled = true; |
25 | @observable customIconUrl = ''; | 26 | @observable customIconUrl = ''; |
27 | @observable hasCrashed = false; | ||
26 | 28 | ||
27 | constructor(data, recipe) { | 29 | constructor(data, recipe) { |
28 | if (!data) { | 30 | if (!data) { |
@@ -53,14 +55,25 @@ export default class Service { | |||
53 | this.isIndirectMessageBadgeEnabled = data.isIndirectMessageBadgeEnabled !== undefined | 55 | this.isIndirectMessageBadgeEnabled = data.isIndirectMessageBadgeEnabled !== undefined |
54 | ? data.isIndirectMessageBadgeEnabled : this.isIndirectMessageBadgeEnabled; | 56 | ? data.isIndirectMessageBadgeEnabled : this.isIndirectMessageBadgeEnabled; |
55 | 57 | ||
58 | this.isMuted = data.isMuted !== undefined ? data.isMuted : this.isMuted; | ||
59 | |||
56 | this.recipe = recipe; | 60 | this.recipe = recipe; |
61 | |||
62 | autorun(() => { | ||
63 | if (!this.isEnabled) { | ||
64 | this.webview = null; | ||
65 | this.isAttached = false; | ||
66 | this.unreadDirectMessageCount = 0; | ||
67 | this.unreadIndirectMessageCount = 0; | ||
68 | } | ||
69 | }); | ||
57 | } | 70 | } |
58 | 71 | ||
59 | @computed get url() { | 72 | @computed get url() { |
60 | if (this.recipe.hasCustomUrl && this.customUrl) { | 73 | if (this.recipe.hasCustomUrl && this.customUrl) { |
61 | let url; | 74 | let url; |
62 | try { | 75 | try { |
63 | url = normalizeUrl(this.customUrl); | 76 | url = normalizeUrl(this.customUrl, { stripWWW: false }); |
64 | } catch (err) { | 77 | } catch (err) { |
65 | console.error(`Service (${this.recipe.name}): '${this.customUrl}' is not a valid Url.`); | 78 | console.error(`Service (${this.recipe.name}): '${this.customUrl}' is not a valid Url.`); |
66 | } | 79 | } |
@@ -117,6 +130,14 @@ export default class Service { | |||
117 | frameName, | 130 | frameName, |
118 | options, | 131 | options, |
119 | })); | 132 | })); |
133 | |||
134 | this.webview.addEventListener('did-start-loading', () => { | ||
135 | this.hasCrashed = false; | ||
136 | }); | ||
137 | |||
138 | this.webview.addEventListener('crashed', () => { | ||
139 | this.hasCrashed = true; | ||
140 | }); | ||
120 | } | 141 | } |
121 | 142 | ||
122 | initializeWebViewListener() { | 143 | initializeWebViewListener() { |