diff options
author | Stefan Malzner <stefan@adlk.io> | 2017-12-24 22:11:36 +0100 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2017-12-24 22:11:36 +0100 |
commit | df44b69c4655415fe1e44689ece443ec06ef0f52 (patch) | |
tree | e677ed5f5328bb3b14bc976c7392d8e259f89034 /src/models/Service.js | |
parent | [wip] add icon upload (diff) | |
parent | Merge pull request #494 from heavypackets/websecurity-enable-patch (diff) | |
download | ferdium-app-df44b69c4655415fe1e44689ece443ec06ef0f52.tar.gz ferdium-app-df44b69c4655415fe1e44689ece443ec06ef0f52.tar.zst ferdium-app-df44b69c4655415fe1e44689ece443ec06ef0f52.zip |
Merge branch 'develop' into feature/icon-upload
Diffstat (limited to 'src/models/Service.js')
-rw-r--r-- | src/models/Service.js | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/models/Service.js b/src/models/Service.js index eb68493fe..0b19440e7 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 | ||
@@ -22,6 +22,7 @@ export default class Service { | |||
22 | @observable team = ''; | 22 | @observable team = ''; |
23 | @observable customUrl = ''; | 23 | @observable customUrl = ''; |
24 | @observable isNotificationEnabled = true; | 24 | @observable isNotificationEnabled = true; |
25 | @observable isBadgeEnabled = true; | ||
25 | @observable isIndirectMessageBadgeEnabled = true; | 26 | @observable isIndirectMessageBadgeEnabled = true; |
26 | @observable customIconUrl = ''; | 27 | @observable customIconUrl = ''; |
27 | @observable hasCrashed = false; | 28 | @observable hasCrashed = false; |
@@ -52,19 +53,31 @@ export default class Service { | |||
52 | this.isNotificationEnabled = data.isNotificationEnabled !== undefined | 53 | this.isNotificationEnabled = data.isNotificationEnabled !== undefined |
53 | ? data.isNotificationEnabled : this.isNotificationEnabled; | 54 | ? data.isNotificationEnabled : this.isNotificationEnabled; |
54 | 55 | ||
56 | this.isBadgeEnabled = data.isBadgeEnabled !== undefined | ||
57 | ? data.isBadgeEnabled : this.isBadgeEnabled; | ||
58 | |||
55 | this.isIndirectMessageBadgeEnabled = data.isIndirectMessageBadgeEnabled !== undefined | 59 | this.isIndirectMessageBadgeEnabled = data.isIndirectMessageBadgeEnabled !== undefined |
56 | ? data.isIndirectMessageBadgeEnabled : this.isIndirectMessageBadgeEnabled; | 60 | ? data.isIndirectMessageBadgeEnabled : this.isIndirectMessageBadgeEnabled; |
57 | 61 | ||
58 | this.isMuted = data.isMuted !== undefined ? data.isMuted : this.isMuted; | 62 | this.isMuted = data.isMuted !== undefined ? data.isMuted : this.isMuted; |
59 | 63 | ||
60 | this.recipe = recipe; | 64 | this.recipe = recipe; |
65 | |||
66 | autorun(() => { | ||
67 | if (!this.isEnabled) { | ||
68 | this.webview = null; | ||
69 | this.isAttached = false; | ||
70 | this.unreadDirectMessageCount = 0; | ||
71 | this.unreadIndirectMessageCount = 0; | ||
72 | } | ||
73 | }); | ||
61 | } | 74 | } |
62 | 75 | ||
63 | @computed get url() { | 76 | @computed get url() { |
64 | if (this.recipe.hasCustomUrl && this.customUrl) { | 77 | if (this.recipe.hasCustomUrl && this.customUrl) { |
65 | let url; | 78 | let url; |
66 | try { | 79 | try { |
67 | url = normalizeUrl(this.customUrl); | 80 | url = normalizeUrl(this.customUrl, { stripWWW: false }); |
68 | } catch (err) { | 81 | } catch (err) { |
69 | console.error(`Service (${this.recipe.name}): '${this.customUrl}' is not a valid Url.`); | 82 | console.error(`Service (${this.recipe.name}): '${this.customUrl}' is not a valid Url.`); |
70 | } | 83 | } |