diff options
Diffstat (limited to 'src/containers/settings/RecipesScreen.tsx')
-rw-r--r-- | src/containers/settings/RecipesScreen.tsx | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/containers/settings/RecipesScreen.tsx b/src/containers/settings/RecipesScreen.tsx index fffdd39fa..abbb79b39 100644 --- a/src/containers/settings/RecipesScreen.tsx +++ b/src/containers/settings/RecipesScreen.tsx | |||
@@ -16,27 +16,30 @@ import RecipePreview from '../../models/RecipePreview'; | |||
16 | import { openPath } from '../../helpers/url-helpers'; | 16 | import { openPath } from '../../helpers/url-helpers'; |
17 | import withParams from '../../components/util/WithParams'; | 17 | import withParams from '../../components/util/WithParams'; |
18 | 18 | ||
19 | interface RecipesScreenProps extends StoresProps { | 19 | interface IProps extends Partial<StoresProps> { |
20 | params: Params; | 20 | params: Params; |
21 | } | 21 | } |
22 | 22 | ||
23 | class RecipesScreen extends Component<RecipesScreenProps> { | 23 | interface IState { |
24 | state: { | 24 | needle: string | null; |
25 | needle: string | null; | 25 | currentFilter: string; |
26 | currentFilter: string; | 26 | } |
27 | } = { | ||
28 | needle: null, | ||
29 | currentFilter: 'featured', | ||
30 | }; | ||
31 | 27 | ||
28 | @inject('stores', 'actions') | ||
29 | @observer | ||
30 | class RecipesScreen extends Component<IProps, IState> { | ||
32 | autorunDisposer: IReactionDisposer | null = null; | 31 | autorunDisposer: IReactionDisposer | null = null; |
33 | 32 | ||
34 | customRecipes: Recipe[] = []; | 33 | customRecipes: Recipe[] = []; |
35 | 34 | ||
36 | constructor(props: RecipesScreenProps) { | 35 | constructor(props: IProps) { |
37 | super(props); | 36 | super(props); |
38 | 37 | ||
39 | this.customRecipes = readJsonSync(asarRecipesPath('all.json')); | 38 | this.customRecipes = readJsonSync(asarRecipesPath('all.json')); |
39 | this.state = { | ||
40 | needle: null, | ||
41 | currentFilter: 'featured', | ||
42 | }; | ||
40 | } | 43 | } |
41 | 44 | ||
42 | componentDidMount(): void { | 45 | componentDidMount(): void { |
@@ -55,7 +58,7 @@ class RecipesScreen extends Component<RecipesScreenProps> { | |||
55 | } | 58 | } |
56 | 59 | ||
57 | componentWillUnmount(): void { | 60 | componentWillUnmount(): void { |
58 | this.props.stores.services.resetStatus(); | 61 | this.props.stores!.services.resetStatus(); |
59 | 62 | ||
60 | if (typeof this.autorunDisposer === 'function') { | 63 | if (typeof this.autorunDisposer === 'function') { |
61 | this.autorunDisposer(); | 64 | this.autorunDisposer(); |
@@ -66,7 +69,7 @@ class RecipesScreen extends Component<RecipesScreenProps> { | |||
66 | if (needle === '') { | 69 | if (needle === '') { |
67 | this.resetSearch(); | 70 | this.resetSearch(); |
68 | } else { | 71 | } else { |
69 | const { search } = this.props.actions.recipePreview; | 72 | const { search } = this.props.actions!.recipePreview; |
70 | this.setState({ needle }); | 73 | this.setState({ needle }); |
71 | search({ needle }); | 74 | search({ needle }); |
72 | } | 75 | } |
@@ -106,10 +109,8 @@ class RecipesScreen extends Component<RecipesScreenProps> { | |||
106 | } | 109 | } |
107 | 110 | ||
108 | render(): ReactElement { | 111 | render(): ReactElement { |
109 | const { recipePreviews, recipes, services } = this.props.stores; | 112 | const { recipePreviews, recipes, services } = this.props.stores!; |
110 | 113 | const { app: appActions, service: serviceActions } = this.props.actions!; | |
111 | const { app: appActions, service: serviceActions } = this.props.actions; | ||
112 | |||
113 | const filter = this.state.currentFilter; | 114 | const filter = this.state.currentFilter; |
114 | 115 | ||
115 | let recipeFilter; | 116 | let recipeFilter; |
@@ -163,7 +164,6 @@ class RecipesScreen extends Component<RecipesScreenProps> { | |||
163 | recipes={allRecipes} | 164 | recipes={allRecipes} |
164 | customWebsiteRecipe={customWebsiteRecipe} | 165 | customWebsiteRecipe={customWebsiteRecipe} |
165 | isLoading={isLoading} | 166 | isLoading={isLoading} |
166 | addedServiceCount={services.all.length} | ||
167 | hasLoadedRecipes={ | 167 | hasLoadedRecipes={ |
168 | recipePreviews.featuredRecipePreviewsRequest.wasExecuted | 168 | recipePreviews.featuredRecipePreviewsRequest.wasExecuted |
169 | } | 169 | } |
@@ -184,4 +184,4 @@ class RecipesScreen extends Component<RecipesScreenProps> { | |||
184 | } | 184 | } |
185 | } | 185 | } |
186 | 186 | ||
187 | export default withParams(inject('stores', 'actions')(observer(RecipesScreen))); | 187 | export default withParams(RecipesScreen); |