diff options
Diffstat (limited to 'src/stores/ServicesStore.js')
-rw-r--r-- | src/stores/ServicesStore.js | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index 349de2c9b..ee47bf6db 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -149,18 +149,7 @@ export default class ServicesStore extends Store { | |||
149 | } | 149 | } |
150 | 150 | ||
151 | async _showAddServiceInterface({ recipeId }) { | 151 | async _showAddServiceInterface({ recipeId }) { |
152 | const recipesStore = this.stores.recipes; | 152 | this.stores.router.push(`/settings/services/add/${recipeId}`); |
153 | |||
154 | if (recipesStore.isInstalled(recipeId)) { | ||
155 | debug(`Recipe ${recipeId} is installed`); | ||
156 | this._redirectToAddServiceRoute(recipeId); | ||
157 | } else { | ||
158 | debug(`Recipe ${recipeId} is not installed`); | ||
159 | // We access the RecipeStore action directly | ||
160 | // returns Promise instead of action | ||
161 | await this.stores.recipes._install({ recipeId }); | ||
162 | this._redirectToAddServiceRoute(recipeId); | ||
163 | } | ||
164 | } | 153 | } |
165 | 154 | ||
166 | // Actions | 155 | // Actions |
@@ -294,7 +283,8 @@ export default class ServicesStore extends Store { | |||
294 | gaEvent('Service', 'clear cache'); | 283 | gaEvent('Service', 'clear cache'); |
295 | } | 284 | } |
296 | 285 | ||
297 | @action _setActive({ serviceId }) { | 286 | @action _setActive({ serviceId, keepActiveRoute }) { |
287 | if (!keepActiveRoute) this.stores.router.push('/'); | ||
298 | const service = this.one(serviceId); | 288 | const service = this.one(serviceId); |
299 | 289 | ||
300 | this.all.forEach((s, index) => { | 290 | this.all.forEach((s, index) => { |
@@ -520,7 +510,16 @@ export default class ServicesStore extends Store { | |||
520 | this.actions.ui.toggleServiceUpdatedInfoBar({ visible: false }); | 510 | this.actions.ui.toggleServiceUpdatedInfoBar({ visible: false }); |
521 | } | 511 | } |
522 | 512 | ||
523 | @action _reorder({ oldIndex, newIndex }) { | 513 | @action _reorder(params) { |
514 | const { workspaces } = this.stores; | ||
515 | if (workspaces.isAnyWorkspaceActive) { | ||
516 | workspaces.reorderServicesOfActiveWorkspace(params); | ||
517 | } else { | ||
518 | this._reorderService(params); | ||
519 | } | ||
520 | } | ||
521 | |||
522 | @action _reorderService({ oldIndex, newIndex }) { | ||
524 | const showDisabledServices = this.stores.settings.all.app.showDisabledServices; | 523 | const showDisabledServices = this.stores.settings.all.app.showDisabledServices; |
525 | const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]); | 524 | const oldEnabledSortIndex = showDisabledServices ? oldIndex : this.all.indexOf(this.enabled[oldIndex]); |
526 | const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]); | 525 | const newEnabledSortIndex = showDisabledServices ? newIndex : this.all.indexOf(this.enabled[newIndex]); |
@@ -683,11 +682,6 @@ export default class ServicesStore extends Store { | |||
683 | } | 682 | } |
684 | 683 | ||
685 | // Helper | 684 | // Helper |
686 | _redirectToAddServiceRoute(recipeId) { | ||
687 | const route = `/settings/services/add/${recipeId}`; | ||
688 | this.stores.router.push(route); | ||
689 | } | ||
690 | |||
691 | _initializeServiceRecipeInWebview(serviceId) { | 685 | _initializeServiceRecipeInWebview(serviceId) { |
692 | const service = this.one(serviceId); | 686 | const service = this.one(serviceId); |
693 | 687 | ||