diff options
author | Stefan Malzner <stefan@adlk.io> | 2019-06-14 17:21:33 +0200 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2019-06-14 17:21:33 +0200 |
commit | b0e2f5cb5ea7109a81b1f9404fed084a25996efb (patch) | |
tree | 1df0700fa627a10971db62421bf6383cf3ce4080 /src/features | |
parent | Restrict services with customURL when not premium user (diff) | |
parent | Fix issue with dev recipe list (diff) | |
download | ferdium-app-b0e2f5cb5ea7109a81b1f9404fed084a25996efb.tar.gz ferdium-app-b0e2f5cb5ea7109a81b1f9404fed084a25996efb.tar.zst ferdium-app-b0e2f5cb5ea7109a81b1f9404fed084a25996efb.zip |
Merge branch 'feature/3rd-party-limit' into feature/new-pricing
Diffstat (limited to 'src/features')
-rw-r--r-- | src/features/communityRecipes/index.js | 28 | ||||
-rw-r--r-- | src/features/communityRecipes/store.js | 31 |
2 files changed, 59 insertions, 0 deletions
diff --git a/src/features/communityRecipes/index.js b/src/features/communityRecipes/index.js new file mode 100644 index 000000000..78e87855e --- /dev/null +++ b/src/features/communityRecipes/index.js | |||
@@ -0,0 +1,28 @@ | |||
1 | import { reaction } from 'mobx'; | ||
2 | import { CommunityRecipesStore } from './store'; | ||
3 | |||
4 | const debug = require('debug')('Franz:feature:communityRecipes'); | ||
5 | |||
6 | export const DEFAULT_SERVICE_LIMIT = 3; | ||
7 | |||
8 | export const communityRecipesStore = new CommunityRecipesStore(); | ||
9 | |||
10 | export default function initCommunityRecipes(stores, actions) { | ||
11 | const { features } = stores; | ||
12 | |||
13 | communityRecipesStore.start(stores, actions); | ||
14 | |||
15 | // Toggle communityRecipe premium status | ||
16 | reaction( | ||
17 | () => ( | ||
18 | features.features.isCommunityRecipesPremiumFeature | ||
19 | ), | ||
20 | (isPremiumFeature) => { | ||
21 | debug('Community recipes is premium feature: ', isPremiumFeature); | ||
22 | communityRecipesStore.isCommunityRecipesPremiumFeature = isPremiumFeature; | ||
23 | }, | ||
24 | { | ||
25 | fireImmediately: true, | ||
26 | }, | ||
27 | ); | ||
28 | } | ||
diff --git a/src/features/communityRecipes/store.js b/src/features/communityRecipes/store.js new file mode 100644 index 000000000..165b753e8 --- /dev/null +++ b/src/features/communityRecipes/store.js | |||
@@ -0,0 +1,31 @@ | |||
1 | import { computed, observable } from 'mobx'; | ||
2 | import { FeatureStore } from '../utils/FeatureStore'; | ||
3 | |||
4 | const debug = require('debug')('Franz:feature:communityRecipes:store'); | ||
5 | |||
6 | export class CommunityRecipesStore extends FeatureStore { | ||
7 | @observable isCommunityRecipesPremiumFeature = false; | ||
8 | |||
9 | start(stores, actions) { | ||
10 | debug('start'); | ||
11 | this.stores = stores; | ||
12 | this.actions = actions; | ||
13 | } | ||
14 | |||
15 | stop() { | ||
16 | debug('stop'); | ||
17 | super.stop(); | ||
18 | } | ||
19 | |||
20 | @computed get communityRecipes() { | ||
21 | if (!this.stores) return []; | ||
22 | |||
23 | return this.stores.recipePreviews.dev.map((r) => { | ||
24 | r.isDevRecipe = !!r.author.find(a => a.email === this.stores.user.data.email); | ||
25 | |||
26 | return r; | ||
27 | }); | ||
28 | } | ||
29 | } | ||
30 | |||
31 | export default CommunityRecipesStore; | ||