diff options
author | Stefan Malzner <stefan@adlk.io> | 2019-06-13 15:16:57 +0200 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2019-06-13 15:16:57 +0200 |
commit | 97852499feba82003021c501b97b075e11647f5e (patch) | |
tree | 1cbd4031cc8a3910e511a1013a2af54fc38bc353 /src/stores/ServicesStore.js | |
parent | Improve serviceLimit implementation (diff) | |
download | ferdium-app-97852499feba82003021c501b97b075e11647f5e.tar.gz ferdium-app-97852499feba82003021c501b97b075e11647f5e.tar.zst ferdium-app-97852499feba82003021c501b97b075e11647f5e.zip |
Add "service limit reached" screen
Diffstat (limited to 'src/stores/ServicesStore.js')
-rw-r--r-- | src/stores/ServicesStore.js | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index ee47bf6db..79d1a0ea1 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -93,13 +93,21 @@ export default class ServicesStore extends Store { | |||
93 | () => this.stores.settings.app.spellcheckerLanguage, | 93 | () => this.stores.settings.app.spellcheckerLanguage, |
94 | () => this._shareSettingsWithServiceProcess(), | 94 | () => this._shareSettingsWithServiceProcess(), |
95 | ); | 95 | ); |
96 | |||
97 | reaction( | ||
98 | () => this.all, | ||
99 | () => this._restrictServiceAccess(), | ||
100 | ); | ||
96 | } | 101 | } |
97 | 102 | ||
98 | @computed get all() { | 103 | @computed get all() { |
99 | if (this.stores.user.isLoggedIn) { | 104 | if (this.stores.user.isLoggedIn) { |
100 | const services = this.allServicesRequest.execute().result; | 105 | const services = this.allServicesRequest.execute().result; |
101 | if (services) { | 106 | if (services) { |
102 | return observable(services.slice().slice().sort((a, b) => a.order - b.order)); | 107 | return observable(services.slice().slice().sort((a, b) => a.order - b.order).map((s, index) => { |
108 | s.index = index; | ||
109 | return s; | ||
110 | })); | ||
103 | } | 111 | } |
104 | } | 112 | } |
105 | return []; | 113 | return []; |
@@ -681,6 +689,20 @@ export default class ServicesStore extends Store { | |||
681 | return serviceData; | 689 | return serviceData; |
682 | } | 690 | } |
683 | 691 | ||
692 | _restrictServiceAccess() { | ||
693 | const services = this.all; | ||
694 | const { userHasReachedServiceLimit, serviceLimit } = this.stores.serviceLimit; | ||
695 | |||
696 | if (userHasReachedServiceLimit) { | ||
697 | services.map((service, index) => { | ||
698 | console.log('restrictServiceAcceess', index >= serviceLimit); | ||
699 | service.isServiceAccessRestricted = index >= serviceLimit; | ||
700 | |||
701 | return service; | ||
702 | }); | ||
703 | } | ||
704 | } | ||
705 | |||
684 | // Helper | 706 | // Helper |
685 | _initializeServiceRecipeInWebview(serviceId) { | 707 | _initializeServiceRecipeInWebview(serviceId) { |
686 | const service = this.one(serviceId); | 708 | const service = this.one(serviceId); |