aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/communityRecipes/store.js
blob: 05e18e2f7709a6c84a8e5098b63efcfe8863a9e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { computed } from 'mobx';
import { FeatureStore } from '../utils/FeatureStore';

const debug = require('debug')('Ferdi:feature:communityRecipes:store');

export class CommunityRecipesStore extends FeatureStore {
  start(stores, actions) {
    debug('start');
    this.stores = stores;
    this.actions = actions;
  }

  stop() {
    debug('stop');
    super.stop();
  }

  @computed get communityRecipes() {
    if (!this.stores) return [];

    return this.stores.recipePreviews.dev.map(recipePreview => {
      // TODO: Need to figure out if this is even necessary/used
      recipePreview.isDevRecipe = !!recipePreview.author.some(
        author => author.email === this.stores.user.data.email,
      );

      return recipePreview;
    });
  }
}

export default CommunityRecipesStore;