aboutsummaryrefslogtreecommitdiffstats
path: root/src/containers
diff options
context:
space:
mode:
authorLibravatar Vijay A <avijayr@protonmail.com>2021-08-17 16:43:44 +0530
committerLibravatar Vijay A <avijayr@protonmail.com>2021-08-17 17:15:42 +0530
commitcc398c4cdcd11afaf2340e28c0c453fad7147332 (patch)
tree1811bc95a1642fe58dad2cc8ee984741b24e8d63 /src/containers
parent5.6.1-nightly.30 [skip ci] (diff)
downloadferdium-app-cc398c4cdcd11afaf2340e28c0c453fad7147332.tar.gz
ferdium-app-cc398c4cdcd11afaf2340e28c0c453fad7147332.tar.zst
ferdium-app-cc398c4cdcd11afaf2340e28c0c453fad7147332.zip
fix: sorted the recipes according to their service name
Diffstat (limited to 'src/containers')
-rw-r--r--src/containers/settings/RecipesScreen.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/containers/settings/RecipesScreen.js b/src/containers/settings/RecipesScreen.js
index fa8245c6e..784052bbe 100644
--- a/src/containers/settings/RecipesScreen.js
+++ b/src/containers/settings/RecipesScreen.js
@@ -74,6 +74,12 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend
74 } 74 }
75 } 75 }
76 76
77 _sortByName(recipe1, recipe2) {
78 if (recipe1.name.toLowerCase() < recipe2.name.toLowerCase()) { return -1; }
79 if (recipe1.name.toLowerCase() > recipe2.name.toLowerCase()) { return 1; }
80 return 0;
81 }
82
77 prepareRecipes(recipes) { 83 prepareRecipes(recipes) {
78 return recipes 84 return recipes
79 // Filter out duplicate recipes 85 // Filter out duplicate recipes
@@ -82,11 +88,7 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend
82 return ids.indexOf(recipe.id) === index; 88 return ids.indexOf(recipe.id) === index;
83 89
84 // Sort alphabetically 90 // Sort alphabetically
85 }).sort((a, b) => { 91 }).sort(this._sortByName);
86 if (a.id < b.id) { return -1; }
87 if (a.id > b.id) { return 1; }
88 return 0;
89 });
90 } 92 }
91 93
92 // Create an array of RecipePreviews from an array of recipe objects 94 // Create an array of RecipePreviews from an array of recipe objects
@@ -121,6 +123,7 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend
121 } else if (filter === 'dev') { 123 } else if (filter === 'dev') {
122 recipeFilter = communityRecipesStore.communityRecipes; 124 recipeFilter = communityRecipesStore.communityRecipes;
123 } 125 }
126 recipeFilter = recipeFilter.sort(this._sortByName);
124 127
125 const allRecipes = this.state.needle ? this.prepareRecipes([ 128 const allRecipes = this.state.needle ? this.prepareRecipes([
126 // All search recipes from server 129 // All search recipes from server
@@ -130,7 +133,7 @@ export default @inject('stores', 'actions') @observer class RecipesScreen extend
130 this.customRecipes 133 this.customRecipes
131 .filter((service) => service.name.toLowerCase().includes(this.state.needle.toLowerCase()) || (service.aliases || []).some(alias => alias.toLowerCase().includes(this.state.needle.toLowerCase()))), 134 .filter((service) => service.name.toLowerCase().includes(this.state.needle.toLowerCase()) || (service.aliases || []).some(alias => alias.toLowerCase().includes(this.state.needle.toLowerCase()))),
132 ), 135 ),
133 ]) : recipeFilter; 136 ]).sort(this._sortByName) : recipeFilter;
134 137
135 const customWebsiteRecipe = recipePreviews.all.find((service) => service.id === CUSTOM_WEBSITE_RECIPE_ID); 138 const customWebsiteRecipe = recipePreviews.all.find((service) => service.id === CUSTOM_WEBSITE_RECIPE_ID);
136 139