From 7040eaeacc295b8c1b19a32ce802060279a378da Mon Sep 17 00:00:00 2001 From: vantezzen Date: Sat, 28 Sep 2019 17:04:16 +0200 Subject: Fix loading of recipe information --- src/containers/settings/RecipesScreen.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/containers/settings/RecipesScreen.js b/src/containers/settings/RecipesScreen.js index cff6bfd83..70b599d9c 100644 --- a/src/containers/settings/RecipesScreen.js +++ b/src/containers/settings/RecipesScreen.js @@ -1,4 +1,5 @@ import { remote, shell } from 'electron'; +import fs from 'fs-extra'; import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { autorun } from 'mobx'; @@ -12,12 +13,10 @@ import UserStore from '../../stores/UserStore'; import RecipesDashboard from '../../components/settings/recipes/RecipesDashboard'; import ErrorBoundary from '../../components/util/ErrorBoundary'; -import { FRANZ_DEV_DOCS } from '../../config'; +import { FRANZ_DEV_DOCS, RECIPES_PATH } from '../../config'; import { communityRecipesStore } from '../../features/communityRecipes'; import RecipePreview from '../../models/RecipePreview'; -import allFerdiRecipes from '../../../recipes/all.json'; - const { app } = remote; export default @inject('stores', 'actions') @observer class RecipesScreen extends Component { @@ -40,6 +39,14 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend autorunDisposer = null; + customRecipes = []; + + constructor(props) { + super(props); + + this.customRecipes = fs.readJsonSync(path.join(RECIPES_PATH, 'all.json')); + } + componentDidMount() { this.autorunDisposer = autorun(() => { const { filter } = this.props.params; @@ -114,7 +121,7 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend if (filter === 'all') { recipeFilter = this.prepareRecipes([ ...recipePreviews.all, - ...this.createPreviews(allFerdiRecipes), + ...this.createPreviews(this.customRecipes), ]); } else if (filter === 'dev') { recipeFilter = communityRecipesStore.communityRecipes; @@ -127,7 +134,7 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend ...recipePreviews.searchResults, // All search recipes from local recipes ...this.createPreviews( - allFerdiRecipes + this.customRecipes .filter(service => service.name.toLowerCase().includes(this.state.needle.toLowerCase())), ), ]) : recipeFilter; -- cgit v1.2.3-70-g09d2