aboutsummaryrefslogtreecommitdiffstats
path: root/src/stores/ServicesStore.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/stores/ServicesStore.js')
-rw-r--r--src/stores/ServicesStore.js26
1 files changed, 5 insertions, 21 deletions
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js
index 2fc543192..876851a66 100644
--- a/src/stores/ServicesStore.js
+++ b/src/stores/ServicesStore.js
@@ -4,14 +4,13 @@ import {
4 computed, 4 computed,
5 observable, 5 observable,
6} from 'mobx'; 6} from 'mobx';
7import { debounce, remove } from 'lodash'; 7import { remove } from 'lodash';
8import ms from 'ms'; 8import ms from 'ms';
9 9
10import Store from './lib/Store'; 10import Store from './lib/Store';
11import Request from './lib/Request'; 11import Request from './lib/Request';
12import CachedRequest from './lib/CachedRequest'; 12import CachedRequest from './lib/CachedRequest';
13import { matchRoute } from '../helpers/routing-helpers'; 13import { matchRoute } from '../helpers/routing-helpers';
14import { gaEvent, statsEvent } from '../lib/analytics';
15import { workspaceStore } from '../features/workspaces'; 14import { workspaceStore } from '../features/workspaces';
16import { serviceLimitStore } from '../features/serviceLimit'; 15import { serviceLimitStore } from '../features/serviceLimit';
17import { RESTRICTION_TYPES } from '../models/Service'; 16import { RESTRICTION_TYPES } from '../models/Service';
@@ -181,7 +180,6 @@ export default class ServicesStore extends Store {
181 180
182 if (redirect) { 181 if (redirect) {
183 this.stores.router.push('/settings/recipes'); 182 this.stores.router.push('/settings/recipes');
184 gaEvent('Service', 'create', recipeId);
185 } 183 }
186 } 184 }
187 185
@@ -258,7 +256,6 @@ export default class ServicesStore extends Store {
258 256
259 if (redirect) { 257 if (redirect) {
260 this.stores.router.push('/settings/services'); 258 this.stores.router.push('/settings/services');
261 gaEvent('Service', 'update', service.recipe.id);
262 } 259 }
263 } 260 }
264 261
@@ -273,19 +270,14 @@ export default class ServicesStore extends Store {
273 remove(result, c => c.id === serviceId); 270 remove(result, c => c.id === serviceId);
274 }); 271 });
275 272
276 const service = this.one(serviceId);
277
278 await request._promise; 273 await request._promise;
279 this.actionStatus = request.result.status; 274 this.actionStatus = request.result.status;
280
281 gaEvent('Service', 'delete', service.recipe.id);
282 } 275 }
283 276
284 @action async _clearCache({ serviceId }) { 277 @action async _clearCache({ serviceId }) {
285 this.clearCacheRequest.reset(); 278 this.clearCacheRequest.reset();
286 const request = this.clearCacheRequest.execute(serviceId); 279 const request = this.clearCacheRequest.execute(serviceId);
287 await request._promise; 280 await request._promise;
288 gaEvent('Service', 'clear cache');
289 } 281 }
290 282
291 @action _setActive({ serviceId, keepActiveRoute }) { 283 @action _setActive({ serviceId, keepActiveRoute }) {
@@ -297,8 +289,6 @@ export default class ServicesStore extends Store {
297 }); 289 });
298 service.isActive = true; 290 service.isActive = true;
299 291
300 statsEvent('activate-service', service.recipe.id);
301
302 this._focusActiveService(); 292 this._focusActiveService();
303 } 293 }
304 294
@@ -401,7 +391,7 @@ export default class ServicesStore extends Store {
401 }, 391 },
402 }); 392 });
403 } else if (channel === 'notification') { 393 } else if (channel === 'notification') {
404 const options = args[0].options; 394 const { options } = args[0];
405 if (service.recipe.hasNotificationSound || service.isMuted || this.stores.settings.all.app.isAppMuted) { 395 if (service.recipe.hasNotificationSound || service.isMuted || this.stores.settings.all.app.isAppMuted) {
406 Object.assign(options, { 396 Object.assign(options, {
407 silent: true, 397 silent: true,
@@ -528,7 +518,7 @@ export default class ServicesStore extends Store {
528 } 518 }
529 519
530 @action _reorderService({ oldIndex, newIndex }) { 520 @action _reorderService({ oldIndex, newIndex }) {
531 const showDisabledServices = this.stores.settings.all.app.showDisabledServices; 521 const { showDisabledServices } = this.stores.settings.all.app;
532 const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]); 522 const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]);
533 const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]); 523 const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]);
534 524
@@ -547,8 +537,6 @@ export default class ServicesStore extends Store {
547 service.order = services[s.id]; 537 service.order = services[s.id];
548 }); 538 });
549 }); 539 });
550
551 this._reorderAnalytics();
552 } 540 }
553 541
554 @action _toggleNotifications({ serviceId }) { 542 @action _toggleNotifications({ serviceId }) {
@@ -624,8 +612,8 @@ export default class ServicesStore extends Store {
624 } 612 }
625 613
626 _getUnreadMessageCountReaction() { 614 _getUnreadMessageCountReaction() {
627 const showMessageBadgeWhenMuted = this.stores.settings.all.app.showMessageBadgeWhenMuted; 615 const { showMessageBadgeWhenMuted } = this.stores.settings.all.app;
628 const showMessageBadgesEvenWhenMuted = this.stores.ui.showMessageBadgesEvenWhenMuted; 616 const { showMessageBadgesEvenWhenMuted } = this.stores.ui;
629 617
630 const unreadDirectMessageCount = this.allDisplayed 618 const unreadDirectMessageCount = this.allDisplayed
631 .filter(s => (showMessageBadgeWhenMuted || s.isNotificationEnabled) && showMessageBadgesEvenWhenMuted && s.isBadgeEnabled) 619 .filter(s => (showMessageBadgeWhenMuted || s.isNotificationEnabled) && showMessageBadgesEvenWhenMuted && s.isBadgeEnabled)
@@ -750,10 +738,6 @@ export default class ServicesStore extends Store {
750 } 738 }
751 } 739 }
752 740
753 _reorderAnalytics = debounce(() => {
754 gaEvent('Service', 'order');
755 }, ms('5s'));
756
757 _wrapIndex(index, delta, size) { 741 _wrapIndex(index, delta, size) {
758 return (((index + delta) % size) + size) % size; 742 return (((index + delta) % size) + size) % size;
759 } 743 }