diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/Controllers/Http/RecipeController.js | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/app/Controllers/Http/RecipeController.js b/app/Controllers/Http/RecipeController.js index 17b35fb..7109d2d 100644 --- a/app/Controllers/Http/RecipeController.js +++ b/app/Controllers/Http/RecipeController.js | |||
@@ -138,7 +138,7 @@ class RecipeController { | |||
138 | 138 | ||
139 | // Get results | 139 | // Get results |
140 | let remoteResults = []; | 140 | let remoteResults = []; |
141 | if (Env.get('CONNECT_WITH_FRANZ') == 'true') { // eslint-disable-line eqeqeq | 141 | if (Env.get('CONNECT_WITH_FRANZ') == 'true' && needle !== 'ferdi:custom') { // eslint-disable-line eqeqeq |
142 | remoteResults = JSON.parse(await (await fetch(`https://api.franzinfra.com/v1/recipes/search?needle=${encodeURIComponent(needle)}`)).text()); | 142 | remoteResults = JSON.parse(await (await fetch(`https://api.franzinfra.com/v1/recipes/search?needle=${encodeURIComponent(needle)}`)).text()); |
143 | } | 143 | } |
144 | const localResultsArray = (await Recipe.query().where('name', 'LIKE', `%${needle}%`).fetch()).toJSON(); | 144 | const localResultsArray = (await Recipe.query().where('name', 'LIKE', `%${needle}%`).fetch()).toJSON(); |
@@ -148,10 +148,15 @@ class RecipeController { | |||
148 | ...JSON.parse(recipe.data), | 148 | ...JSON.parse(recipe.data), |
149 | })); | 149 | })); |
150 | 150 | ||
151 | const results = [ | 151 | let results; |
152 | ...localResults, | 152 | if (needle === 'ferdi:custom') { |
153 | ...remoteResults, | 153 | results = localResults; |
154 | ]; | 154 | } else { |
155 | results = [ | ||
156 | ...localResults, | ||
157 | ...remoteResults || [], | ||
158 | ]; | ||
159 | } | ||
155 | 160 | ||
156 | return response.send(results); | 161 | return response.send(results); |
157 | } | 162 | } |