From 99d1c014efb273d25a5d73780c403427fb51a229 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Sun, 22 Oct 2017 21:12:45 +0200 Subject: fix(Onboarding): Fix service import Fixes #22 --- src/stores/UserStore.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/stores/UserStore.js') diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js index 4927d615f..1cb2ecac3 100644 --- a/src/stores/UserStore.js +++ b/src/stores/UserStore.js @@ -192,6 +192,15 @@ export default class UserStore extends Store { @action async _importLegacyServices({ services }) { this.isImportLegacyServicesExecuting = true; + // Reduces recipe duplicates + const recipes = services.filter((obj, pos, arr) => arr.map(mapObj => mapObj.recipe.id).indexOf(obj.recipe.id) === pos).map(s => s.recipe.id); + + // Install recipes + for (const recipe of recipes) { + // eslint-disable-next-line + await this.stores.recipes._install({ recipeId: recipe }); + } + for (const service of services) { this.actions.service.createFromLegacyService({ data: service, -- cgit v1.2.3-70-g09d2