From d7bc95b8d52d4916f88b141ca96f842fc777854c Mon Sep 17 00:00:00 2001 From: vantezzen Date: Fri, 6 Sep 2019 12:12:02 +0200 Subject: Add search query for listing custom recipes --- app/Controllers/Http/RecipeController.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'app/Controllers') 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 { // Get results let remoteResults = []; - if (Env.get('CONNECT_WITH_FRANZ') == 'true') { // eslint-disable-line eqeqeq + if (Env.get('CONNECT_WITH_FRANZ') == 'true' && needle !== 'ferdi:custom') { // eslint-disable-line eqeqeq remoteResults = JSON.parse(await (await fetch(`https://api.franzinfra.com/v1/recipes/search?needle=${encodeURIComponent(needle)}`)).text()); } const localResultsArray = (await Recipe.query().where('name', 'LIKE', `%${needle}%`).fetch()).toJSON(); @@ -148,10 +148,15 @@ class RecipeController { ...JSON.parse(recipe.data), })); - const results = [ - ...localResults, - ...remoteResults, - ]; + let results; + if (needle === 'ferdi:custom') { + results = localResults; + } else { + results = [ + ...localResults, + ...remoteResults || [], + ]; + } return response.send(results); } -- cgit v1.2.3-54-g00ecf