diff options
author | 2019-06-14 15:29:04 +0200 | |
---|---|---|
committer | 2019-06-14 15:29:04 +0200 | |
commit | bbfb750bafadae49116b1a420664ea753cd9b50b (patch) | |
tree | dddf11190cfdcfaa8171f7609b1e4d5dd0654dff /src/stores/ServicesStore.js | |
parent | Add "service limit reached" screen (diff) | |
download | ferdium-app-bbfb750bafadae49116b1a420664ea753cd9b50b.tar.gz ferdium-app-bbfb750bafadae49116b1a420664ea753cd9b50b.tar.zst ferdium-app-bbfb750bafadae49116b1a420664ea753cd9b50b.zip |
Restrict services with customURL when not premium user
Diffstat (limited to 'src/stores/ServicesStore.js')
-rw-r--r-- | src/stores/ServicesStore.js | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 79d1a0ea1..4cffea110 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -14,6 +14,7 @@ import { matchRoute } from '../helpers/routing-helpers'; | |||
14 | import { gaEvent, statsEvent } from '../lib/analytics'; | 14 | import { gaEvent, statsEvent } from '../lib/analytics'; |
15 | import { workspaceStore } from '../features/workspaces'; | 15 | import { workspaceStore } from '../features/workspaces'; |
16 | import { serviceLimitStore } from '../features/serviceLimit'; | 16 | import { serviceLimitStore } from '../features/serviceLimit'; |
17 | import { RESTRICTION_TYPES } from '../models/Service'; | ||
17 | 18 | ||
18 | const debug = require('debug')('Franz:ServiceStore'); | 19 | const debug = require('debug')('Franz:ServiceStore'); |
19 | 20 | ||
@@ -76,6 +77,7 @@ export default class ServicesStore extends Store { | |||
76 | this._saveActiveService.bind(this), | 77 | this._saveActiveService.bind(this), |
77 | this._logoutReaction.bind(this), | 78 | this._logoutReaction.bind(this), |
78 | this._handleMuteSettings.bind(this), | 79 | this._handleMuteSettings.bind(this), |
80 | this._restrictServiceAccess.bind(this), | ||
79 | ]); | 81 | ]); |
80 | 82 | ||
81 | // Just bind this | 83 | // Just bind this |
@@ -93,11 +95,6 @@ export default class ServicesStore extends Store { | |||
93 | () => this.stores.settings.app.spellcheckerLanguage, | 95 | () => this.stores.settings.app.spellcheckerLanguage, |
94 | () => this._shareSettingsWithServiceProcess(), | 96 | () => this._shareSettingsWithServiceProcess(), |
95 | ); | 97 | ); |
96 | |||
97 | reaction( | ||
98 | () => this.all, | ||
99 | () => this._restrictServiceAccess(), | ||
100 | ); | ||
101 | } | 98 | } |
102 | 99 | ||
103 | @computed get all() { | 100 | @computed get all() { |
@@ -690,17 +687,30 @@ export default class ServicesStore extends Store { | |||
690 | } | 687 | } |
691 | 688 | ||
692 | _restrictServiceAccess() { | 689 | _restrictServiceAccess() { |
693 | const services = this.all; | 690 | const { features } = this.stores.features; |
694 | const { userHasReachedServiceLimit, serviceLimit } = this.stores.serviceLimit; | 691 | const { userHasReachedServiceLimit, serviceLimit } = this.stores.serviceLimit; |
695 | 692 | ||
696 | if (userHasReachedServiceLimit) { | 693 | this.all.map((service, index) => { |
697 | services.map((service, index) => { | 694 | if (userHasReachedServiceLimit) { |
698 | console.log('restrictServiceAcceess', index >= serviceLimit); | ||
699 | service.isServiceAccessRestricted = index >= serviceLimit; | 695 | service.isServiceAccessRestricted = index >= serviceLimit; |
696 | service.restrictionType = RESTRICTION_TYPES.SERVICE_LIMIT; | ||
700 | 697 | ||
701 | return service; | 698 | if (index >= serviceLimit) { |
702 | }); | 699 | debug('Restricting access to server due to service limit'); |
703 | } | 700 | } |
701 | } | ||
702 | |||
703 | if (service.isUsingCustomUrl) { | ||
704 | service.isServiceAccessRestricted = features.isCustomUrlPremiumFeature; | ||
705 | service.restrictionType = RESTRICTION_TYPES.CUSTOM_URL; | ||
706 | |||
707 | if (features.isCustomUrlPremiumFeature) { | ||
708 | debug('Restricting access to server due to custom url'); | ||
709 | } | ||
710 | } | ||
711 | |||
712 | return service; | ||
713 | }); | ||
704 | } | 714 | } |
705 | 715 | ||
706 | // Helper | 716 | // Helper |