diff options
author | 2019-09-28 17:04:16 +0200 | |
---|---|---|
committer | 2019-09-28 17:04:16 +0200 | |
commit | 7040eaeacc295b8c1b19a32ce802060279a378da (patch) | |
tree | 107a3c5b6a624fc96e0c6b1e1e3b5eb601429d9a /src/containers | |
parent | Replace "invite friends" screen with "support Ferdi" screen (diff) | |
download | ferdium-app-7040eaeacc295b8c1b19a32ce802060279a378da.tar.gz ferdium-app-7040eaeacc295b8c1b19a32ce802060279a378da.tar.zst ferdium-app-7040eaeacc295b8c1b19a32ce802060279a378da.zip |
Fix loading of recipe information
Diffstat (limited to 'src/containers')
-rw-r--r-- | src/containers/settings/RecipesScreen.js | 17 |
1 files changed, 12 insertions, 5 deletions
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 @@ | |||
1 | import { remote, shell } from 'electron'; | 1 | import { remote, shell } from 'electron'; |
2 | import fs from 'fs-extra'; | ||
2 | import React, { Component } from 'react'; | 3 | import React, { Component } from 'react'; |
3 | import PropTypes from 'prop-types'; | 4 | import PropTypes from 'prop-types'; |
4 | import { autorun } from 'mobx'; | 5 | import { autorun } from 'mobx'; |
@@ -12,12 +13,10 @@ import UserStore from '../../stores/UserStore'; | |||
12 | 13 | ||
13 | import RecipesDashboard from '../../components/settings/recipes/RecipesDashboard'; | 14 | import RecipesDashboard from '../../components/settings/recipes/RecipesDashboard'; |
14 | import ErrorBoundary from '../../components/util/ErrorBoundary'; | 15 | import ErrorBoundary from '../../components/util/ErrorBoundary'; |
15 | import { FRANZ_DEV_DOCS } from '../../config'; | 16 | import { FRANZ_DEV_DOCS, RECIPES_PATH } from '../../config'; |
16 | import { communityRecipesStore } from '../../features/communityRecipes'; | 17 | import { communityRecipesStore } from '../../features/communityRecipes'; |
17 | import RecipePreview from '../../models/RecipePreview'; | 18 | import RecipePreview from '../../models/RecipePreview'; |
18 | 19 | ||
19 | import allFerdiRecipes from '../../../recipes/all.json'; | ||
20 | |||
21 | const { app } = remote; | 20 | const { app } = remote; |
22 | 21 | ||
23 | export default @inject('stores', 'actions') @observer class RecipesScreen extends Component { | 22 | export default @inject('stores', 'actions') @observer class RecipesScreen extends Component { |
@@ -40,6 +39,14 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend | |||
40 | 39 | ||
41 | autorunDisposer = null; | 40 | autorunDisposer = null; |
42 | 41 | ||
42 | customRecipes = []; | ||
43 | |||
44 | constructor(props) { | ||
45 | super(props); | ||
46 | |||
47 | this.customRecipes = fs.readJsonSync(path.join(RECIPES_PATH, 'all.json')); | ||
48 | } | ||
49 | |||
43 | componentDidMount() { | 50 | componentDidMount() { |
44 | this.autorunDisposer = autorun(() => { | 51 | this.autorunDisposer = autorun(() => { |
45 | const { filter } = this.props.params; | 52 | const { filter } = this.props.params; |
@@ -114,7 +121,7 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend | |||
114 | if (filter === 'all') { | 121 | if (filter === 'all') { |
115 | recipeFilter = this.prepareRecipes([ | 122 | recipeFilter = this.prepareRecipes([ |
116 | ...recipePreviews.all, | 123 | ...recipePreviews.all, |
117 | ...this.createPreviews(allFerdiRecipes), | 124 | ...this.createPreviews(this.customRecipes), |
118 | ]); | 125 | ]); |
119 | } else if (filter === 'dev') { | 126 | } else if (filter === 'dev') { |
120 | recipeFilter = communityRecipesStore.communityRecipes; | 127 | recipeFilter = communityRecipesStore.communityRecipes; |
@@ -127,7 +134,7 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend | |||
127 | ...recipePreviews.searchResults, | 134 | ...recipePreviews.searchResults, |
128 | // All search recipes from local recipes | 135 | // All search recipes from local recipes |
129 | ...this.createPreviews( | 136 | ...this.createPreviews( |
130 | allFerdiRecipes | 137 | this.customRecipes |
131 | .filter(service => service.name.toLowerCase().includes(this.state.needle.toLowerCase())), | 138 | .filter(service => service.name.toLowerCase().includes(this.state.needle.toLowerCase())), |
132 | ), | 139 | ), |
133 | ]) : recipeFilter; | 140 | ]) : recipeFilter; |