diff options
author | MCMXC <16797721+mcmxcdev@users.noreply.github.com> | 2023-07-29 21:12:16 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-30 08:42:16 +0530 |
commit | 32f76b74a69ad4d60a014bf075c39517888436bc (patch) | |
tree | 753378cc30f52d1e0e51be64b5a83d39f08f39c8 /src/stores/ServicesStore.ts | |
parent | 6.4.1-nightly.15 [skip ci] (diff) | |
download | ferdium-app-32f76b74a69ad4d60a014bf075c39517888436bc.tar.gz ferdium-app-32f76b74a69ad4d60a014bf075c39517888436bc.tar.zst ferdium-app-32f76b74a69ad4d60a014bf075c39517888436bc.zip |
refactor: various improvements (#1296)
* refactor: various improvements
- enable no-use-before-define eslint rule
- shuffle code to conform to no-use-before-define eslint rule
- remove btoa dependency which is deprecated and replace with Buffer.from(string).toString('base64')
- convert some any types into useful ones
- add type annotations where possible
- remove unused @types/expect.js
- install @types/semver and ts-node which were missing
- repair and rewrite add-crowdin-contributors script
- remove export keyword from variables which are never consumed in another file
- remove unity indicator hack where linked issue was closed
- remove module declaration for kebab-case which is unused
- add missing state interface for certain components
- remove default exports for files which already have a named export
- export IRecipePreview so it can be used throughout codebase
- remove unused removeCacheForCallWith method from CachedRequest.ts
- cleanup unused colors and styles inside legacy theme
* - improve ColorPickerInput
- fix invalid DOM nesting with div inside p in EditSettingsForm
- fix progressbarAccentColor color picker not updating input when using slider
- install missing @types/react-color dependency
Diffstat (limited to 'src/stores/ServicesStore.ts')
-rw-r--r-- | src/stores/ServicesStore.ts | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/stores/ServicesStore.ts b/src/stores/ServicesStore.ts index 7f4693cad..82f3b95ce 100644 --- a/src/stores/ServicesStore.ts +++ b/src/stores/ServicesStore.ts | |||
@@ -594,7 +594,7 @@ export default class ServicesStore extends TypedStore { | |||
594 | this.stores.router.push(redirect); | 594 | this.stores.router.push(redirect); |
595 | } | 595 | } |
596 | 596 | ||
597 | this.allServicesRequest.patch(result => { | 597 | this.allServicesRequest.patch((result: Service[]) => { |
598 | remove(result, (c: Service) => c.id === serviceId); | 598 | remove(result, (c: Service) => c.id === serviceId); |
599 | }); | 599 | }); |
600 | 600 | ||
@@ -606,7 +606,7 @@ export default class ServicesStore extends TypedStore { | |||
606 | // Get directory for recipe | 606 | // Get directory for recipe |
607 | const normalDirectory = getRecipeDirectory(recipe); | 607 | const normalDirectory = getRecipeDirectory(recipe); |
608 | const devDirectory = getDevRecipeDirectory(recipe); | 608 | const devDirectory = getDevRecipeDirectory(recipe); |
609 | let directory; | 609 | let directory: string; |
610 | 610 | ||
611 | if (pathExistsSync(normalDirectory)) { | 611 | if (pathExistsSync(normalDirectory)) { |
612 | directory = normalDirectory; | 612 | directory = normalDirectory; |
@@ -1028,7 +1028,7 @@ export default class ServicesStore extends TypedStore { | |||
1028 | } | 1028 | } |
1029 | 1029 | ||
1030 | this.reorderServicesRequest.execute(services); | 1030 | this.reorderServicesRequest.execute(services); |
1031 | this.allServicesRequest.patch(data => { | 1031 | this.allServicesRequest.patch((data: Service[]) => { |
1032 | for (const s of data) { | 1032 | for (const s of data) { |
1033 | s.order = services[s.id]; | 1033 | s.order = services[s.id]; |
1034 | } | 1034 | } |
@@ -1172,7 +1172,7 @@ export default class ServicesStore extends TypedStore { | |||
1172 | ); | 1172 | ); |
1173 | 1173 | ||
1174 | // eslint-disable-next-line unicorn/consistent-function-scoping | 1174 | // eslint-disable-next-line unicorn/consistent-function-scoping |
1175 | const resetTimer = service => { | 1175 | const resetTimer = (service: Service) => { |
1176 | service.lastPollAnswer = Date.now(); | 1176 | service.lastPollAnswer = Date.now(); |
1177 | service.lastPoll = Date.now(); | 1177 | service.lastPoll = Date.now(); |
1178 | }; | 1178 | }; |
@@ -1306,7 +1306,7 @@ export default class ServicesStore extends TypedStore { | |||
1306 | }); | 1306 | }); |
1307 | } | 1307 | } |
1308 | 1308 | ||
1309 | _cleanUpTeamIdAndCustomUrl(recipeId, data): any { | 1309 | _cleanUpTeamIdAndCustomUrl(recipeId: string, data: Service): any { |
1310 | const serviceData = data; | 1310 | const serviceData = data; |
1311 | const recipe = this.stores.recipes.one(recipeId); | 1311 | const recipe = this.stores.recipes.one(recipeId); |
1312 | 1312 | ||
@@ -1318,6 +1318,7 @@ export default class ServicesStore extends TypedStore { | |||
1318 | data.team && | 1318 | data.team && |
1319 | data.customUrl | 1319 | data.customUrl |
1320 | ) { | 1320 | ) { |
1321 | // @ts-expect-error The operand of a 'delete' operator must be optional. | ||
1321 | delete serviceData.team; | 1322 | delete serviceData.team; |
1322 | } | 1323 | } |
1323 | 1324 | ||
@@ -1343,7 +1344,7 @@ export default class ServicesStore extends TypedStore { | |||
1343 | } | 1344 | } |
1344 | 1345 | ||
1345 | // Helper | 1346 | // Helper |
1346 | _initializeServiceRecipeInWebview(serviceId) { | 1347 | _initializeServiceRecipeInWebview(serviceId: string) { |
1347 | const service = this.one(serviceId); | 1348 | const service = this.one(serviceId); |
1348 | 1349 | ||
1349 | if (service.webview) { | 1350 | if (service.webview) { |
@@ -1362,7 +1363,7 @@ export default class ServicesStore extends TypedStore { | |||
1362 | } | 1363 | } |
1363 | } | 1364 | } |
1364 | 1365 | ||
1365 | _initRecipePolling(serviceId) { | 1366 | _initRecipePolling(serviceId: string) { |
1366 | const service = this.one(serviceId); | 1367 | const service = this.one(serviceId); |
1367 | 1368 | ||
1368 | const delay = ms('2s'); | 1369 | const delay = ms('2s'); |
@@ -1385,7 +1386,7 @@ export default class ServicesStore extends TypedStore { | |||
1385 | } | 1386 | } |
1386 | } | 1387 | } |
1387 | 1388 | ||
1388 | _wrapIndex(index, delta, size) { | 1389 | _wrapIndex(index: number, delta: number, size: number) { |
1389 | return (((index + delta) % size) + size) % size; | 1390 | return (((index + delta) % size) + size) % size; |
1390 | } | 1391 | } |
1391 | } | 1392 | } |