aboutsummaryrefslogtreecommitdiffstats
path: root/src/containers/settings/RecipesScreen.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/containers/settings/RecipesScreen.tsx')
-rw-r--r--src/containers/settings/RecipesScreen.tsx17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/containers/settings/RecipesScreen.tsx b/src/containers/settings/RecipesScreen.tsx
index bc7fa9ba0..fffdd39fa 100644
--- a/src/containers/settings/RecipesScreen.tsx
+++ b/src/containers/settings/RecipesScreen.tsx
@@ -3,6 +3,7 @@ import { Component, ReactElement } from 'react';
3import { autorun, IReactionDisposer } from 'mobx'; 3import { autorun, IReactionDisposer } from 'mobx';
4import { inject, observer } from 'mobx-react'; 4import { inject, observer } from 'mobx-react';
5 5
6import { Params } from 'react-router-dom';
6import Recipe from '../../models/Recipe'; 7import Recipe from '../../models/Recipe';
7import { StoresProps } from '../../@types/ferdium-components.types'; 8import { StoresProps } from '../../@types/ferdium-components.types';
8import RecipesDashboard from '../../components/settings/recipes/RecipesDashboard'; 9import RecipesDashboard from '../../components/settings/recipes/RecipesDashboard';
@@ -13,11 +14,10 @@ import { asarRecipesPath } from '../../helpers/asar-helpers';
13import { communityRecipesStore } from '../../features/communityRecipes'; 14import { communityRecipesStore } from '../../features/communityRecipes';
14import RecipePreview from '../../models/RecipePreview'; 15import RecipePreview from '../../models/RecipePreview';
15import { openPath } from '../../helpers/url-helpers'; 16import { openPath } from '../../helpers/url-helpers';
17import withParams from '../../components/util/WithParams';
16 18
17interface RecipesScreenProps extends StoresProps { 19interface RecipesScreenProps extends StoresProps {
18 params: { 20 params: Params;
19 filter?: string | null;
20 };
21} 21}
22 22
23class RecipesScreen extends Component<RecipesScreenProps> { 23class RecipesScreen extends Component<RecipesScreenProps> {
@@ -36,8 +36,6 @@ class RecipesScreen extends Component<RecipesScreenProps> {
36 constructor(props: RecipesScreenProps) { 36 constructor(props: RecipesScreenProps) {
37 super(props); 37 super(props);
38 38
39 this.props.params.filter = this.props.params.filter || null;
40
41 this.customRecipes = readJsonSync(asarRecipesPath('all.json')); 39 this.customRecipes = readJsonSync(asarRecipesPath('all.json'));
42 } 40 }
43 41
@@ -104,7 +102,7 @@ class RecipesScreen extends Component<RecipesScreenProps> {
104 } 102 }
105 103
106 resetSearch(): void { 104 resetSearch(): void {
107 this.setState({ needle: null }); 105 this.setState({ needle: null, currentFilter: 'featured' });
108 } 106 }
109 107
110 render(): ReactElement { 108 render(): ReactElement {
@@ -112,7 +110,8 @@ class RecipesScreen extends Component<RecipesScreenProps> {
112 110
113 const { app: appActions, service: serviceActions } = this.props.actions; 111 const { app: appActions, service: serviceActions } = this.props.actions;
114 112
115 const { filter } = this.props.params; 113 const filter = this.state.currentFilter;
114
116 let recipeFilter; 115 let recipeFilter;
117 116
118 if (filter === 'all') { 117 if (filter === 'all') {
@@ -125,7 +124,7 @@ class RecipesScreen extends Component<RecipesScreenProps> {
125 } else { 124 } else {
126 recipeFilter = recipePreviews.featured; 125 recipeFilter = recipePreviews.featured;
127 } 126 }
128 recipeFilter = recipeFilter.sort(this._sortByName); 127 recipeFilter = [...recipeFilter].sort(this._sortByName);
129 128
130 const { needle } = this.state; 129 const { needle } = this.state;
131 const allRecipes = 130 const allRecipes =
@@ -185,4 +184,4 @@ class RecipesScreen extends Component<RecipesScreenProps> {
185 } 184 }
186} 185}
187 186
188export default inject('stores', 'actions')(observer(RecipesScreen)); 187export default withParams(inject('stores', 'actions')(observer(RecipesScreen)));