aboutsummaryrefslogtreecommitdiffstats
path: root/src/models/Service.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/models/Service.js')
-rw-r--r--src/models/Service.js17
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 @@
1import { computed, observable } from 'mobx'; 1import { computed, observable, autorun } from 'mobx';
2import path from 'path'; 2import path from 'path';
3import normalizeUrl from 'normalize-url'; 3import 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 }