From eba50bc5a41b8492c0350b73936405eab1b8c453 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Wed, 12 Jun 2019 15:16:56 +0200 Subject: fix(Recipes): Fix recipe install when directly accessing recipe --- src/stores/RecipesStore.js | 27 +++++++++++++++++++++++++++ src/stores/ServicesStore.js | 18 +----------------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/stores/RecipesStore.js b/src/stores/RecipesStore.js index ab64bf79c..d51192078 100644 --- a/src/stores/RecipesStore.js +++ b/src/stores/RecipesStore.js @@ -20,6 +20,11 @@ export default class RecipesStore extends Store { // Register action handlers this.actions.recipe.install.listen(this._install.bind(this)); this.actions.recipe.update.listen(this._update.bind(this)); + + // Reactions + this.registerReactions([ + this._checkIfRecipeIsInstalled.bind(this), + ]); } setup() { @@ -99,4 +104,26 @@ export default class RecipesStore extends Store { syncUpdate(0); } } + + async _checkIfRecipeIsInstalled() { + const { router } = this.stores; + + const match = matchRoute('/settings/services/add/:id', router.location.pathname); + if (match) { + const recipeId = match.id; + + if (!this.stores.recipes.isInstalled(recipeId)) { + router.push('/settings/recipes'); + debug(`Recipe ${recipeId} is not installed, trying to install it`); + + const recipe = await this.installRecipeRequest.execute(recipeId)._promise; + if (recipe) { + await this.allRecipesRequest.invalidate({ immediately: true })._promise; + router.push(`/settings/services/add/${recipeId}`); + } else { + router.push('/settings/recipes'); + } + } + } + } } diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index d63302fce..109ac5cd7 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js @@ -148,18 +148,7 @@ export default class ServicesStore extends Store { } async _showAddServiceInterface({ recipeId }) { - const recipesStore = this.stores.recipes; - - if (recipesStore.isInstalled(recipeId)) { - debug(`Recipe ${recipeId} is installed`); - this._redirectToAddServiceRoute(recipeId); - } else { - debug(`Recipe ${recipeId} is not installed`); - // We access the RecipeStore action directly - // returns Promise instead of action - await this.stores.recipes._install({ recipeId }); - this._redirectToAddServiceRoute(recipeId); - } + this.stores.router.push(`/settings/services/add/${recipeId}`); } // Actions @@ -690,11 +679,6 @@ export default class ServicesStore extends Store { } // Helper - _redirectToAddServiceRoute(recipeId) { - const route = `/settings/services/add/${recipeId}`; - this.stores.router.push(route); - } - _initializeServiceRecipeInWebview(serviceId) { const service = this.one(serviceId); -- cgit v1.2.3-70-g09d2 From 3d2c3a228e07a484015e4cf0d4d968fb0155326b Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Wed, 12 Jun 2019 16:36:50 +0200 Subject: bump version to beta 2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3df95362d..9060c32db 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "franz", "productName": "Franz", "appId": "com.meetfranz.franz", - "version": "5.2.0-beta.1", + "version": "5.2.0-beta.2", "description": "Messaging app for WhatsApp, Slack, Telegram, HipChat, Hangouts and many many more.", "copyright": "adlk x franz - Stefan Malzner", "main": "index.js", -- cgit v1.2.3-70-g09d2 From 414bad81be54476d93b91cc620c1b18d925e5970 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Wed, 12 Jun 2019 16:36:55 +0200 Subject: Update CHANGELOG.md --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 469e4fb22..e1fe2ab45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# [5.2.0-beta.2](https://github.com/meetfranz/franz/compare/v5.2.0-beta.1...v5.2.0-beta.2) (2019-06-12) + + +### Bug Fixes + +* **Recipes:** Fix recipe install when directly accessing recipe ([eba50bc](https://github.com/meetfranz/franz/commit/eba50bc)) + + + # [5.2.0-beta.1](https://github.com/meetfranz/franz/compare/v5.1.0...v5.2.0-beta.1) (2019-06-11) -- cgit v1.2.3-70-g09d2