diff options
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/RecipesStore.js | 8 | ||||
-rw-r--r-- | src/stores/RequestStore.js | 4 | ||||
-rw-r--r-- | src/stores/ServicesStore.js | 16 |
3 files changed, 19 insertions, 9 deletions
diff --git a/src/stores/RecipesStore.js b/src/stores/RecipesStore.js index 67fee1d50..a24308f6a 100644 --- a/src/stores/RecipesStore.js +++ b/src/stores/RecipesStore.js | |||
@@ -5,6 +5,8 @@ import CachedRequest from './lib/CachedRequest'; | |||
5 | import Request from './lib/Request'; | 5 | import Request from './lib/Request'; |
6 | import { matchRoute } from '../helpers/routing-helpers'; | 6 | import { matchRoute } from '../helpers/routing-helpers'; |
7 | 7 | ||
8 | const debug = require('debug')('RecipeStore'); | ||
9 | |||
8 | export default class RecipesStore extends Store { | 10 | export default class RecipesStore extends Store { |
9 | @observable allRecipesRequest = new CachedRequest(this.api.recipes, 'all'); | 11 | @observable allRecipesRequest = new CachedRequest(this.api.recipes, 'all'); |
10 | @observable installRecipeRequest = new Request(this.api.recipes, 'install'); | 12 | @observable installRecipeRequest = new Request(this.api.recipes, 'install'); |
@@ -34,7 +36,7 @@ export default class RecipesStore extends Store { | |||
34 | return activeRecipe; | 36 | return activeRecipe; |
35 | } | 37 | } |
36 | 38 | ||
37 | console.warn('Recipe not installed'); | 39 | debug(`Recipe ${match.id} not installed`); |
38 | } | 40 | } |
39 | 41 | ||
40 | return null; | 42 | return null; |
@@ -54,10 +56,8 @@ export default class RecipesStore extends Store { | |||
54 | 56 | ||
55 | // Actions | 57 | // Actions |
56 | @action async _install({ recipeId }) { | 58 | @action async _install({ recipeId }) { |
57 | // console.log(this.installRecipeRequest._promise); | ||
58 | const recipe = await this.installRecipeRequest.execute(recipeId)._promise; | 59 | const recipe = await this.installRecipeRequest.execute(recipeId)._promise; |
59 | await this.allRecipesRequest.invalidate({ immediately: true })._promise; | 60 | await this.allRecipesRequest.invalidate({ immediately: true })._promise; |
60 | // console.log(this.installRecipeRequest._promise); | ||
61 | 61 | ||
62 | return recipe; | 62 | return recipe; |
63 | } | 63 | } |
@@ -67,7 +67,7 @@ export default class RecipesStore extends Store { | |||
67 | const recipes = {}; | 67 | const recipes = {}; |
68 | 68 | ||
69 | // Hackfix, reference this.all to fetch services | 69 | // Hackfix, reference this.all to fetch services |
70 | console.debug(`Check Recipe updates for ${this.all.map(recipe => recipe.id)}`); | 70 | debug(`Check Recipe updates for ${this.all.map(recipe => recipe.id)}`); |
71 | 71 | ||
72 | recipeIds.forEach((r) => { | 72 | recipeIds.forEach((r) => { |
73 | const recipe = this.one(r); | 73 | const recipe = this.one(r); |
diff --git a/src/stores/RequestStore.js b/src/stores/RequestStore.js index 4140ca362..595852583 100644 --- a/src/stores/RequestStore.js +++ b/src/stores/RequestStore.js | |||
@@ -2,6 +2,8 @@ import { action, computed, observable } from 'mobx'; | |||
2 | 2 | ||
3 | import Store from './lib/Store'; | 3 | import Store from './lib/Store'; |
4 | 4 | ||
5 | const debug = require('debug')('RequestsStore'); | ||
6 | |||
5 | export default class RequestStore extends Store { | 7 | export default class RequestStore extends Store { |
6 | @observable userInfoRequest; | 8 | @observable userInfoRequest; |
7 | @observable servicesRequest; | 9 | @observable servicesRequest; |
@@ -52,7 +54,7 @@ export default class RequestStore extends Store { | |||
52 | } | 54 | } |
53 | 55 | ||
54 | this._autoRetry(); | 56 | this._autoRetry(); |
55 | console.debug(`Retry required requests delayed in ${(delay) / 1000}s`); | 57 | debug(`Retry required requests delayed in ${(delay) / 1000}s`); |
56 | }, delay); | 58 | }, delay); |
57 | } | 59 | } |
58 | } | 60 | } |
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index c38d0d9ee..f7d92b1ff 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -10,6 +10,8 @@ import CachedRequest from './lib/CachedRequest'; | |||
10 | import { matchRoute } from '../helpers/routing-helpers'; | 10 | import { matchRoute } from '../helpers/routing-helpers'; |
11 | import { gaEvent } from '../lib/analytics'; | 11 | import { gaEvent } from '../lib/analytics'; |
12 | 12 | ||
13 | const debug = require('debug')('ServiceStore'); | ||
14 | |||
13 | export default class ServicesStore extends Store { | 15 | export default class ServicesStore extends Store { |
14 | @observable allServicesRequest = new CachedRequest(this.api.services, 'all'); | 16 | @observable allServicesRequest = new CachedRequest(this.api.services, 'all'); |
15 | @observable createServiceRequest = new Request(this.api.services, 'create'); | 17 | @observable createServiceRequest = new Request(this.api.services, 'create'); |
@@ -87,6 +89,12 @@ export default class ServicesStore extends Store { | |||
87 | return this.stores.settings.all.showDisabledServices ? this.all : this.enabled; | 89 | return this.stores.settings.all.showDisabledServices ? this.all : this.enabled; |
88 | } | 90 | } |
89 | 91 | ||
92 | // This is just used to avoid unnecessary rerendering of resource-heavy webviews | ||
93 | @computed get allDisplayedUnordered() { | ||
94 | const services = this.allServicesRequest.execute().result || []; | ||
95 | return this.stores.settings.all.showDisabledServices ? services : services.filter(service => service.isEnabled); | ||
96 | } | ||
97 | |||
90 | @computed get filtered() { | 98 | @computed get filtered() { |
91 | return this.all.filter(service => service.name.toLowerCase().includes(this.filterNeedle.toLowerCase())); | 99 | return this.all.filter(service => service.name.toLowerCase().includes(this.filterNeedle.toLowerCase())); |
92 | } | 100 | } |
@@ -103,7 +111,7 @@ export default class ServicesStore extends Store { | |||
103 | return activeService; | 111 | return activeService; |
104 | } | 112 | } |
105 | 113 | ||
106 | console.warn('Service not available'); | 114 | debug('Service not available'); |
107 | } | 115 | } |
108 | 116 | ||
109 | return null; | 117 | return null; |
@@ -117,10 +125,10 @@ export default class ServicesStore extends Store { | |||
117 | const recipesStore = this.stores.recipes; | 125 | const recipesStore = this.stores.recipes; |
118 | 126 | ||
119 | if (recipesStore.isInstalled(recipeId)) { | 127 | if (recipesStore.isInstalled(recipeId)) { |
120 | console.debug('Recipe is installed'); | 128 | debug(`Recipe ${recipeId} is installed`); |
121 | this._redirectToAddServiceRoute(recipeId); | 129 | this._redirectToAddServiceRoute(recipeId); |
122 | } else { | 130 | } else { |
123 | console.warn('Recipe is not installed'); | 131 | debug(`Recipe ${recipeId} is not installed`); |
124 | // We access the RecipeStore action directly | 132 | // We access the RecipeStore action directly |
125 | // returns Promise instead of action | 133 | // returns Promise instead of action |
126 | await this.stores.recipes._install({ recipeId }); | 134 | await this.stores.recipes._install({ recipeId }); |
@@ -487,7 +495,7 @@ export default class ServicesStore extends Store { | |||
487 | if (service) { | 495 | if (service) { |
488 | service.webview.openDevTools(); | 496 | service.webview.openDevTools(); |
489 | } else { | 497 | } else { |
490 | console.warn('No service is active'); | 498 | debug('No service is active'); |
491 | } | 499 | } |
492 | } | 500 | } |
493 | 501 | ||