diff options
author | Ricardo Cino <ricardo@cino.io> | 2022-06-22 22:10:39 +0200 |
---|---|---|
committer | Vijay Aravamudhan <vraravam@users.noreply.github.com> | 2022-06-23 06:55:42 +0530 |
commit | 5dcc1aff28290fe3b7e2ed5cbe99d3034c0b6f34 (patch) | |
tree | 81f643c38eecdfa49476e0b9dac3aed9107ecf99 /src/stores/RecipePreviewsStore.js | |
parent | Upgrade 'electron' to '19.0.6' (diff) | |
download | ferdium-app-5dcc1aff28290fe3b7e2ed5cbe99d3034c0b6f34.tar.gz ferdium-app-5dcc1aff28290fe3b7e2ed5cbe99d3034c0b6f34.tar.zst ferdium-app-5dcc1aff28290fe3b7e2ed5cbe99d3034c0b6f34.zip |
chore: recipes/request stores js => ts
Diffstat (limited to 'src/stores/RecipePreviewsStore.js')
-rw-r--r-- | src/stores/RecipePreviewsStore.js | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/src/stores/RecipePreviewsStore.js b/src/stores/RecipePreviewsStore.js deleted file mode 100644 index ef0bca430..000000000 --- a/src/stores/RecipePreviewsStore.js +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | import { action, computed, observable } from 'mobx'; | ||
2 | |||
3 | import Store from './lib/Store'; | ||
4 | import CachedRequest from './lib/CachedRequest'; | ||
5 | import Request from './lib/Request'; | ||
6 | |||
7 | export default class RecipePreviewsStore extends Store { | ||
8 | @observable allRecipePreviewsRequest = new CachedRequest( | ||
9 | this.api.recipePreviews, | ||
10 | 'all', | ||
11 | ); | ||
12 | |||
13 | @observable featuredRecipePreviewsRequest = new CachedRequest(this.api.recipePreviews, 'featured'); | ||
14 | |||
15 | @observable searchRecipePreviewsRequest = new Request(this.api.recipePreviews, 'search'); | ||
16 | |||
17 | constructor(...args) { | ||
18 | super(...args); | ||
19 | |||
20 | // Register action handlers | ||
21 | this.actions.recipePreview.search.listen(this._search.bind(this)); | ||
22 | } | ||
23 | |||
24 | @computed get all() { | ||
25 | return this.allRecipePreviewsRequest.execute().result || []; | ||
26 | } | ||
27 | |||
28 | @computed get featured() { | ||
29 | return this.featuredRecipePreviewsRequest.execute().result || []; | ||
30 | } | ||
31 | |||
32 | @computed get searchResults() { | ||
33 | return this.searchRecipePreviewsRequest.result || []; | ||
34 | } | ||
35 | |||
36 | @computed get dev() { | ||
37 | return this.stores.recipes.all.filter(r => r.local); | ||
38 | } | ||
39 | |||
40 | // Actions | ||
41 | @action _search({ needle }) { | ||
42 | if (needle !== '') { | ||
43 | this.searchRecipePreviewsRequest.execute(needle); | ||
44 | } | ||
45 | } | ||
46 | } | ||