diff options
author | Ricardo Cino <ricardo@cino.io> | 2022-07-07 09:31:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-07 09:31:50 +0200 |
commit | 71c52373f81cace664047edd19d9d289f45a4dff (patch) | |
tree | 69b3f1d45a8b3f1ceab9497ea3c96e9dc18e3166 /src/containers/settings/RecipesScreen.tsx | |
parent | 6.0.0-nightly.91 [skip ci] (diff) | |
download | ferdium-app-71c52373f81cace664047edd19d9d289f45a4dff.tar.gz ferdium-app-71c52373f81cace664047edd19d9d289f45a4dff.tar.zst ferdium-app-71c52373f81cace664047edd19d9d289f45a4dff.zip |
chore: Mobx & React-Router upgrade (#406)
Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
Diffstat (limited to 'src/containers/settings/RecipesScreen.tsx')
-rw-r--r-- | src/containers/settings/RecipesScreen.tsx | 17 |
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'; | |||
3 | import { autorun, IReactionDisposer } from 'mobx'; | 3 | import { autorun, IReactionDisposer } from 'mobx'; |
4 | import { inject, observer } from 'mobx-react'; | 4 | import { inject, observer } from 'mobx-react'; |
5 | 5 | ||
6 | import { Params } from 'react-router-dom'; | ||
6 | import Recipe from '../../models/Recipe'; | 7 | import Recipe from '../../models/Recipe'; |
7 | import { StoresProps } from '../../@types/ferdium-components.types'; | 8 | import { StoresProps } from '../../@types/ferdium-components.types'; |
8 | import RecipesDashboard from '../../components/settings/recipes/RecipesDashboard'; | 9 | import RecipesDashboard from '../../components/settings/recipes/RecipesDashboard'; |
@@ -13,11 +14,10 @@ import { asarRecipesPath } from '../../helpers/asar-helpers'; | |||
13 | import { communityRecipesStore } from '../../features/communityRecipes'; | 14 | import { communityRecipesStore } from '../../features/communityRecipes'; |
14 | import RecipePreview from '../../models/RecipePreview'; | 15 | import RecipePreview from '../../models/RecipePreview'; |
15 | import { openPath } from '../../helpers/url-helpers'; | 16 | import { openPath } from '../../helpers/url-helpers'; |
17 | import withParams from '../../components/util/WithParams'; | ||
16 | 18 | ||
17 | interface RecipesScreenProps extends StoresProps { | 19 | interface RecipesScreenProps extends StoresProps { |
18 | params: { | 20 | params: Params; |
19 | filter?: string | null; | ||
20 | }; | ||
21 | } | 21 | } |
22 | 22 | ||
23 | class RecipesScreen extends Component<RecipesScreenProps> { | 23 | class 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 | ||
188 | export default inject('stores', 'actions')(observer(RecipesScreen)); | 187 | export default withParams(inject('stores', 'actions')(observer(RecipesScreen))); |