diff options
Diffstat (limited to 'src/features/communityRecipes/store.ts')
-rw-r--r-- | src/features/communityRecipes/store.ts | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/features/communityRecipes/store.ts b/src/features/communityRecipes/store.ts new file mode 100644 index 000000000..a8d358ba0 --- /dev/null +++ b/src/features/communityRecipes/store.ts | |||
@@ -0,0 +1,39 @@ | |||
1 | import { computed } from 'mobx'; | ||
2 | import { FeatureStore } from '../utils/FeatureStore'; | ||
3 | |||
4 | const debug = require('debug')('Ferdi:feature:communityRecipes:store'); | ||
5 | |||
6 | export class CommunityRecipesStore extends FeatureStore { | ||
7 | stores: any; | ||
8 | |||
9 | actions: any; | ||
10 | |||
11 | start(stores: any, actions: any) { | ||
12 | debug('start'); | ||
13 | this.stores = stores; | ||
14 | this.actions = actions; | ||
15 | } | ||
16 | |||
17 | stop() { | ||
18 | debug('stop'); | ||
19 | super.stop(); | ||
20 | } | ||
21 | |||
22 | @computed get communityRecipes() { | ||
23 | if (!this.stores) return []; | ||
24 | |||
25 | return this.stores.recipePreviews.dev.map( | ||
26 | (recipePreview: { isDevRecipe: boolean; author: any[] }) => { | ||
27 | // TODO: Need to figure out if this is even necessary/used | ||
28 | recipePreview.isDevRecipe = !!recipePreview.author.some( | ||
29 | (author: { email: any }) => | ||
30 | author.email === this.stores.user.data.email, | ||
31 | ); | ||
32 | |||
33 | return recipePreview; | ||
34 | }, | ||
35 | ); | ||
36 | } | ||
37 | } | ||
38 | |||
39 | export default CommunityRecipesStore; | ||