diff options
author | Markus Hatvan <markus_hatvan@aon.at> | 2021-10-15 09:48:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-15 09:48:06 +0200 |
commit | 14d2364fc69e0222133115c55a36286986006098 (patch) | |
tree | 9e9b3c41ef742bbe87ca1632b292c67043051957 /src/stores | |
parent | 5.6.3-nightly.34 [skip ci] (diff) | |
download | ferdium-app-14d2364fc69e0222133115c55a36286986006098.tar.gz ferdium-app-14d2364fc69e0222133115c55a36286986006098.tar.zst ferdium-app-14d2364fc69e0222133115c55a36286986006098.zip |
chore: update eslint setup (#2074)
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/RecipePreviewsStore.js | 12 | ||||
-rw-r--r-- | src/stores/ServicesStore.js | 2 | ||||
-rw-r--r-- | src/stores/SettingsStore.js | 6 | ||||
-rw-r--r-- | src/stores/UserStore.js | 2 | ||||
-rw-r--r-- | src/stores/lib/Request.js | 82 | ||||
-rw-r--r-- | src/stores/lib/Store.js | 3 |
6 files changed, 70 insertions, 37 deletions
diff --git a/src/stores/RecipePreviewsStore.js b/src/stores/RecipePreviewsStore.js index f4e39306c..e01e8fc6f 100644 --- a/src/stores/RecipePreviewsStore.js +++ b/src/stores/RecipePreviewsStore.js | |||
@@ -5,9 +5,15 @@ import CachedRequest from './lib/CachedRequest'; | |||
5 | import Request from './lib/Request'; | 5 | import Request from './lib/Request'; |
6 | 6 | ||
7 | export default class RecipePreviewsStore extends Store { | 7 | export default class RecipePreviewsStore extends Store { |
8 | @observable allRecipePreviewsRequest = new CachedRequest(this.api.recipePreviews, 'all'); | 8 | @observable allRecipePreviewsRequest = new CachedRequest( |
9 | this.api.recipePreviews, | ||
10 | 'all', | ||
11 | ); | ||
9 | 12 | ||
10 | @observable searchRecipePreviewsRequest = new Request(this.api.recipePreviews, 'search'); | 13 | @observable searchRecipePreviewsRequest = new Request( |
14 | this.api.recipePreviews, | ||
15 | 'search', | ||
16 | ); | ||
11 | 17 | ||
12 | constructor(...args) { | 18 | constructor(...args) { |
13 | super(...args); | 19 | super(...args); |
@@ -25,7 +31,7 @@ export default class RecipePreviewsStore extends Store { | |||
25 | } | 31 | } |
26 | 32 | ||
27 | @computed get dev() { | 33 | @computed get dev() { |
28 | return this.stores.recipes.all.filter((r) => r.local); | 34 | return this.stores.recipes.all.filter(r => r.local); |
29 | } | 35 | } |
30 | 36 | ||
31 | // Actions | 37 | // Actions |
diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index e27567e8f..5ed9e3534 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js | |||
@@ -394,7 +394,7 @@ export default class ServicesStore extends Store { | |||
394 | } | 394 | } |
395 | 395 | ||
396 | // set default values for serviceData | 396 | // set default values for serviceData |
397 | // eslint-disable-next-line prefer-object-spread | 397 | |
398 | // TODO: How is this different from the defaults of the recipe in 'src/models/Recipe' file? | 398 | // TODO: How is this different from the defaults of the recipe in 'src/models/Recipe' file? |
399 | serviceData = { | 399 | serviceData = { |
400 | isEnabled: true, | 400 | isEnabled: true, |
diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js index ec80fee7c..ac9356404 100644 --- a/src/stores/SettingsStore.js +++ b/src/stores/SettingsStore.js | |||
@@ -2,7 +2,11 @@ import { ipcRenderer } from 'electron'; | |||
2 | import { getCurrentWindow } from '@electron/remote'; | 2 | import { getCurrentWindow } from '@electron/remote'; |
3 | import { action, computed, observable, reaction } from 'mobx'; | 3 | import { action, computed, observable, reaction } from 'mobx'; |
4 | import localStorage from 'mobx-localstorage'; | 4 | import localStorage from 'mobx-localstorage'; |
5 | import { DEFAULT_APP_SETTINGS, FILE_SYSTEM_SETTINGS_TYPES, LOCAL_SERVER } from '../config'; | 5 | import { |
6 | DEFAULT_APP_SETTINGS, | ||
7 | FILE_SYSTEM_SETTINGS_TYPES, | ||
8 | LOCAL_SERVER, | ||
9 | } from '../config'; | ||
6 | import { hash } from '../helpers/password-helpers'; | 10 | import { hash } from '../helpers/password-helpers'; |
7 | import Request from './lib/Request'; | 11 | import Request from './lib/Request'; |
8 | import Store from './lib/Store'; | 12 | import Store from './lib/Store'; |
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js index 9f222d2d3..9a5d8cb30 100644 --- a/src/stores/UserStore.js +++ b/src/stores/UserStore.js | |||
@@ -273,13 +273,11 @@ export default class UserStore extends Store { | |||
273 | 273 | ||
274 | // Install recipes | 274 | // Install recipes |
275 | for (const recipe of recipes) { | 275 | for (const recipe of recipes) { |
276 | // eslint-disable-line no-unused-vars | ||
277 | // eslint-disable-next-line no-await-in-loop | 276 | // eslint-disable-next-line no-await-in-loop |
278 | await this.stores.recipes._install({ recipeId: recipe }); | 277 | await this.stores.recipes._install({ recipeId: recipe }); |
279 | } | 278 | } |
280 | 279 | ||
281 | for (const service of services) { | 280 | for (const service of services) { |
282 | // eslint-disable-line no-unused-vars | ||
283 | this.actions.service.createFromLegacyService({ | 281 | this.actions.service.createFromLegacyService({ |
284 | data: service, | 282 | data: service, |
285 | }); | 283 | }); |
diff --git a/src/stores/lib/Request.js b/src/stores/lib/Request.js index 39f32729a..65871ea17 100644 --- a/src/stores/lib/Request.js +++ b/src/stores/lib/Request.js | |||
@@ -38,42 +38,56 @@ export default class Request { | |||
38 | if (this._isWaitingForResponse) return this; | 38 | if (this._isWaitingForResponse) return this; |
39 | 39 | ||
40 | if (!this._api[this._method]) { | 40 | if (!this._api[this._method]) { |
41 | throw new Error(`Missing method <${this._method}> on api object:`, this._api); | 41 | throw new Error( |
42 | `Missing method <${this._method}> on api object:`, | ||
43 | this._api, | ||
44 | ); | ||
42 | } | 45 | } |
43 | 46 | ||
44 | // This timeout is necessary to avoid warnings from mobx | 47 | // This timeout is necessary to avoid warnings from mobx |
45 | // regarding triggering actions as side-effect of getters | 48 | // regarding triggering actions as side-effect of getters |
46 | setTimeout(action(() => { | 49 | setTimeout( |
47 | this.isExecuting = true; | 50 | action(() => { |
48 | }), 0); | 51 | this.isExecuting = true; |
52 | }), | ||
53 | 0, | ||
54 | ); | ||
49 | 55 | ||
50 | // Issue api call & save it as promise that is handled to update the results of the operation | 56 | // Issue api call & save it as promise that is handled to update the results of the operation |
51 | this._promise = new Promise((resolve, reject) => { | 57 | this._promise = new Promise((resolve, reject) => { |
52 | this._api[this._method](...callArgs) | 58 | this._api[this._method](...callArgs) |
53 | .then((result) => { | 59 | .then(result => { |
54 | setTimeout(action(() => { | 60 | setTimeout( |
55 | this.result = result; | 61 | action(() => { |
56 | if (this._currentApiCall) this._currentApiCall.result = result; | 62 | this.result = result; |
57 | this.isExecuting = false; | 63 | if (this._currentApiCall) this._currentApiCall.result = result; |
58 | this.isError = false; | 64 | this.isExecuting = false; |
59 | this.wasExecuted = true; | 65 | this.isError = false; |
60 | this._isWaitingForResponse = false; | 66 | this.wasExecuted = true; |
61 | this._triggerHooks(); | 67 | this._isWaitingForResponse = false; |
62 | resolve(result); | 68 | this._triggerHooks(); |
63 | }), 1); | 69 | resolve(result); |
70 | }), | ||
71 | 1, | ||
72 | ); | ||
64 | return result; | 73 | return result; |
65 | }) | 74 | }) |
66 | .catch(action((error) => { | 75 | .catch( |
67 | setTimeout(action(() => { | 76 | action(error => { |
68 | this.error = error; | 77 | setTimeout( |
69 | this.isExecuting = false; | 78 | action(() => { |
70 | this.isError = true; | 79 | this.error = error; |
71 | this.wasExecuted = true; | 80 | this.isExecuting = false; |
72 | this._isWaitingForResponse = false; | 81 | this.isError = true; |
73 | this._triggerHooks(); | 82 | this.wasExecuted = true; |
74 | reject(error); | 83 | this._isWaitingForResponse = false; |
75 | }), 1); | 84 | this._triggerHooks(); |
76 | })); | 85 | reject(error); |
86 | }), | ||
87 | 1, | ||
88 | ); | ||
89 | }), | ||
90 | ); | ||
77 | }); | 91 | }); |
78 | 92 | ||
79 | this._isWaitingForResponse = true; | 93 | this._isWaitingForResponse = true; |
@@ -89,7 +103,11 @@ export default class Request { | |||
89 | retry = () => this.reload(); | 103 | retry = () => this.reload(); |
90 | 104 | ||
91 | isExecutingWithArgs(...args) { | 105 | isExecutingWithArgs(...args) { |
92 | return this.isExecuting && this._currentApiCall && isEqual(this._currentApiCall.args, args); | 106 | return ( |
107 | this.isExecuting && | ||
108 | this._currentApiCall && | ||
109 | isEqual(this._currentApiCall.args, args) | ||
110 | ); | ||
93 | } | 111 | } |
94 | 112 | ||
95 | @computed get isExecutingFirstTime() { | 113 | @computed get isExecutingFirstTime() { |
@@ -97,12 +115,18 @@ export default class Request { | |||
97 | } | 115 | } |
98 | 116 | ||
99 | then(...args) { | 117 | then(...args) { |
100 | if (!this._promise) throw new Error('You have to call Request::execute before you can access it as promise'); | 118 | if (!this._promise) |
119 | throw new Error( | ||
120 | 'You have to call Request::execute before you can access it as promise', | ||
121 | ); | ||
101 | return this._promise.then(...args); | 122 | return this._promise.then(...args); |
102 | } | 123 | } |
103 | 124 | ||
104 | catch(...args) { | 125 | catch(...args) { |
105 | if (!this._promise) throw new Error('You have to call Request::execute before you can access it as promise'); | 126 | if (!this._promise) |
127 | throw new Error( | ||
128 | 'You have to call Request::execute before you can access it as promise', | ||
129 | ); | ||
106 | return this._promise.catch(...args); | 130 | return this._promise.catch(...args); |
107 | } | 131 | } |
108 | 132 | ||
diff --git a/src/stores/lib/Store.js b/src/stores/lib/Store.js index b39070ce8..a867c3a46 100644 --- a/src/stores/lib/Store.js +++ b/src/stores/lib/Store.js | |||
@@ -28,7 +28,8 @@ export default class Store { | |||
28 | } | 28 | } |
29 | 29 | ||
30 | registerReactions(reactions) { | 30 | registerReactions(reactions) { |
31 | for (const reaction of reactions) this._reactions.push(new Reaction(reaction)); | 31 | for (const reaction of reactions) |
32 | this._reactions.push(new Reaction(reaction)); | ||
32 | } | 33 | } |
33 | 34 | ||
34 | setup() {} | 35 | setup() {} |