diff options
author | Markus Hatvan <markus_hatvan@aon.at> | 2021-10-02 09:24:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-02 09:24:32 +0200 |
commit | bfe8847d72cd0893230f2e654242658214943e61 (patch) | |
tree | 3384b02ebad7a74cbb106ddd95546e0e24ff0bb8 /src | |
parent | fix: Fix navigation shortcut accelerator for non-macos (fixes #1172) (#2012) (diff) | |
download | ferdium-app-bfe8847d72cd0893230f2e654242658214943e61.tar.gz ferdium-app-bfe8847d72cd0893230f2e654242658214943e61.tar.zst ferdium-app-bfe8847d72cd0893230f2e654242658214943e61.zip |
chore: convert various files from JS to TS (#2010)
Diffstat (limited to 'src')
-rw-r--r-- | src/api/AppApi.ts (renamed from src/api/AppApi.js) | 4 | ||||
-rw-r--r-- | src/api/FeaturesApi.ts (renamed from src/api/FeaturesApi.js) | 4 | ||||
-rw-r--r-- | src/api/LocalApi.ts (renamed from src/api/LocalApi.js) | 10 | ||||
-rw-r--r-- | src/api/NewsApi.ts (renamed from src/api/NewsApi.js) | 8 | ||||
-rw-r--r-- | src/api/RecipePreviewsApi.ts (renamed from src/api/RecipePreviewsApi.js) | 6 | ||||
-rw-r--r-- | src/api/RecipesApi.ts (renamed from src/api/RecipesApi.js) | 8 | ||||
-rw-r--r-- | src/api/ServicesApi.ts (renamed from src/api/ServicesApi.js) | 18 | ||||
-rw-r--r-- | src/api/UserApi.ts (renamed from src/api/UserApi.js) | 17 | ||||
-rw-r--r-- | src/api/index.ts (renamed from src/api/index.js) | 10 | ||||
-rw-r--r-- | src/api/utils/auth.ts (renamed from src/api/utils/auth.js) | 8 | ||||
-rw-r--r-- | src/components/settings/services/EditServiceForm.js | 17 | ||||
-rw-r--r-- | src/components/ui/Tabs/TabItem.js | 15 | ||||
-rw-r--r-- | src/components/ui/Tabs/TabItem.tsx | 3 | ||||
-rw-r--r-- | src/components/ui/Tabs/index.js | 6 | ||||
-rw-r--r-- | src/features/basicAuth/Form.ts | 1 | ||||
-rw-r--r-- | src/features/communityRecipes/store.ts (renamed from src/features/communityRecipes/store.js) | 23 | ||||
-rw-r--r-- | src/features/nightlyBuilds/store.ts (renamed from src/features/nightlyBuilds/store.js) | 0 | ||||
-rw-r--r-- | src/features/publishDebugInfo/store.ts (renamed from src/features/publishDebugInfo/store.js) | 0 | ||||
-rw-r--r-- | src/features/quickSwitch/store.ts (renamed from src/features/quickSwitch/store.js) | 0 | ||||
-rw-r--r-- | src/features/serviceProxy/index.js | 38 | ||||
-rw-r--r-- | src/features/serviceProxy/index.ts | 54 | ||||
-rwxr-xr-x | src/features/settingsWS/actions.ts (renamed from src/features/settingsWS/actions.js) | 0 | ||||
-rwxr-xr-x | src/features/settingsWS/index.ts (renamed from src/features/settingsWS/index.js) | 11 | ||||
-rwxr-xr-x | src/features/settingsWS/state.ts (renamed from src/features/settingsWS/state.js) | 0 | ||||
-rw-r--r-- | src/features/todos/actions.js | 28 | ||||
-rw-r--r-- | src/features/todos/actions.ts | 31 | ||||
-rw-r--r-- | src/features/todos/constants.ts (renamed from src/features/todos/constants.js) | 0 | ||||
-rw-r--r-- | src/features/todos/index.ts (renamed from src/features/todos/index.js) | 11 | ||||
-rw-r--r-- | src/lib/DBus.ts (renamed from src/lib/DBus.js) | 22 | ||||
-rw-r--r-- | src/lib/Form.ts (renamed from src/lib/Form.js) | 0 | ||||
-rw-r--r-- | src/lib/TouchBar.ts (renamed from src/lib/TouchBar.js) | 37 |
31 files changed, 227 insertions, 163 deletions
diff --git a/src/api/AppApi.js b/src/api/AppApi.ts index 411c187f4..6e5e5c806 100644 --- a/src/api/AppApi.js +++ b/src/api/AppApi.ts | |||
@@ -1,5 +1,7 @@ | |||
1 | export default class AppApi { | 1 | export default class AppApi { |
2 | constructor(server) { | 2 | server: any; |
3 | |||
4 | constructor(server: any) { | ||
3 | this.server = server; | 5 | this.server = server; |
4 | } | 6 | } |
5 | 7 | ||
diff --git a/src/api/FeaturesApi.js b/src/api/FeaturesApi.ts index c66f28f5b..ccad4a189 100644 --- a/src/api/FeaturesApi.js +++ b/src/api/FeaturesApi.ts | |||
@@ -1,5 +1,7 @@ | |||
1 | export default class FeaturesApi { | 1 | export default class FeaturesApi { |
2 | constructor(server) { | 2 | server: any; |
3 | |||
4 | constructor(server: any) { | ||
3 | this.server = server; | 5 | this.server = server; |
4 | } | 6 | } |
5 | 7 | ||
diff --git a/src/api/LocalApi.js b/src/api/LocalApi.ts index ccdedd3f5..0140a5450 100644 --- a/src/api/LocalApi.js +++ b/src/api/LocalApi.ts | |||
@@ -1,14 +1,18 @@ | |||
1 | export default class LocalApi { | 1 | export default class LocalApi { |
2 | constructor(server, local) { | 2 | server: any; |
3 | |||
4 | local: any; | ||
5 | |||
6 | constructor(server: any, local: any) { | ||
3 | this.server = server; | 7 | this.server = server; |
4 | this.local = local; | 8 | this.local = local; |
5 | } | 9 | } |
6 | 10 | ||
7 | getAppSettings(type) { | 11 | getAppSettings(type: any) { |
8 | return this.local.getAppSettings(type); | 12 | return this.local.getAppSettings(type); |
9 | } | 13 | } |
10 | 14 | ||
11 | updateAppSettings(type, data) { | 15 | updateAppSettings(type: any, data: any) { |
12 | return this.local.updateAppSettings(type, data); | 16 | return this.local.updateAppSettings(type, data); |
13 | } | 17 | } |
14 | 18 | ||
diff --git a/src/api/NewsApi.js b/src/api/NewsApi.ts index 294957511..31d3d903b 100644 --- a/src/api/NewsApi.js +++ b/src/api/NewsApi.ts | |||
@@ -1,5 +1,9 @@ | |||
1 | export default class NewsApi { | 1 | export default class NewsApi { |
2 | constructor(server, local) { | 2 | server: any; |
3 | |||
4 | local: any; | ||
5 | |||
6 | constructor(server: any, local: any) { | ||
3 | this.server = server; | 7 | this.server = server; |
4 | this.local = local; | 8 | this.local = local; |
5 | } | 9 | } |
@@ -8,7 +12,7 @@ export default class NewsApi { | |||
8 | return this.server.getLatestNews(); | 12 | return this.server.getLatestNews(); |
9 | } | 13 | } |
10 | 14 | ||
11 | hide(id) { | 15 | hide(id: any) { |
12 | return this.server.hideNews(id); | 16 | return this.server.hideNews(id); |
13 | } | 17 | } |
14 | } | 18 | } |
diff --git a/src/api/RecipePreviewsApi.js b/src/api/RecipePreviewsApi.ts index a56fa587f..78f2a9596 100644 --- a/src/api/RecipePreviewsApi.js +++ b/src/api/RecipePreviewsApi.ts | |||
@@ -1,5 +1,7 @@ | |||
1 | export default class RecipePreviewsApi { | 1 | export default class RecipePreviewsApi { |
2 | constructor(server) { | 2 | server: any; |
3 | |||
4 | constructor(server: any) { | ||
3 | this.server = server; | 5 | this.server = server; |
4 | } | 6 | } |
5 | 7 | ||
@@ -11,7 +13,7 @@ export default class RecipePreviewsApi { | |||
11 | return this.server.getFeaturedRecipePreviews(); | 13 | return this.server.getFeaturedRecipePreviews(); |
12 | } | 14 | } |
13 | 15 | ||
14 | search(needle) { | 16 | search(needle: string) { |
15 | return this.server.searchRecipePreviews(needle); | 17 | return this.server.searchRecipePreviews(needle); |
16 | } | 18 | } |
17 | } | 19 | } |
diff --git a/src/api/RecipesApi.js b/src/api/RecipesApi.ts index 800888b00..11d2241b5 100644 --- a/src/api/RecipesApi.js +++ b/src/api/RecipesApi.ts | |||
@@ -1,5 +1,7 @@ | |||
1 | export default class RecipesApi { | 1 | export default class RecipesApi { |
2 | constructor(server) { | 2 | server: any; |
3 | |||
4 | constructor(server: any) { | ||
3 | this.server = server; | 5 | this.server = server; |
4 | } | 6 | } |
5 | 7 | ||
@@ -7,11 +9,11 @@ export default class RecipesApi { | |||
7 | return this.server.getInstalledRecipes(); | 9 | return this.server.getInstalledRecipes(); |
8 | } | 10 | } |
9 | 11 | ||
10 | install(recipeId) { | 12 | install(recipeId: string) { |
11 | return this.server.getRecipePackage(recipeId); | 13 | return this.server.getRecipePackage(recipeId); |
12 | } | 14 | } |
13 | 15 | ||
14 | update(recipes) { | 16 | update(recipes: any) { |
15 | return this.server.getRecipeUpdates(recipes); | 17 | return this.server.getRecipeUpdates(recipes); |
16 | } | 18 | } |
17 | } | 19 | } |
diff --git a/src/api/ServicesApi.js b/src/api/ServicesApi.ts index 85efd26a6..5bd8aa60e 100644 --- a/src/api/ServicesApi.js +++ b/src/api/ServicesApi.ts | |||
@@ -1,30 +1,34 @@ | |||
1 | export default class ServicesApi { | 1 | export default class ServicesApi { |
2 | constructor(server, local) { | 2 | server: any; |
3 | this.local = local; | 3 | |
4 | local: any; | ||
5 | |||
6 | constructor(server: any, local: any) { | ||
4 | this.server = server; | 7 | this.server = server; |
8 | this.local = local; | ||
5 | } | 9 | } |
6 | 10 | ||
7 | all() { | 11 | all() { |
8 | return this.server.getServices(); | 12 | return this.server.getServices(); |
9 | } | 13 | } |
10 | 14 | ||
11 | create(recipeId, data) { | 15 | create(recipeId: string, data: any) { |
12 | return this.server.createService(recipeId, data); | 16 | return this.server.createService(recipeId, data); |
13 | } | 17 | } |
14 | 18 | ||
15 | delete(serviceId) { | 19 | delete(serviceId: string) { |
16 | return this.server.deleteService(serviceId); | 20 | return this.server.deleteService(serviceId); |
17 | } | 21 | } |
18 | 22 | ||
19 | update(serviceId, data) { | 23 | update(serviceId: string, data: any) { |
20 | return this.server.updateService(serviceId, data); | 24 | return this.server.updateService(serviceId, data); |
21 | } | 25 | } |
22 | 26 | ||
23 | reorder(data) { | 27 | reorder(data: any) { |
24 | return this.server.reorderService(data); | 28 | return this.server.reorderService(data); |
25 | } | 29 | } |
26 | 30 | ||
27 | clearCache(serviceId) { | 31 | clearCache(serviceId: string) { |
28 | return this.local.clearCache(serviceId); | 32 | return this.local.clearCache(serviceId); |
29 | } | 33 | } |
30 | } | 34 | } |
diff --git a/src/api/UserApi.js b/src/api/UserApi.ts index edfb88988..31c8acead 100644 --- a/src/api/UserApi.js +++ b/src/api/UserApi.ts | |||
@@ -1,12 +1,17 @@ | |||
1 | import { BinaryLike } from 'crypto'; | ||
1 | import { hash } from '../helpers/password-helpers'; | 2 | import { hash } from '../helpers/password-helpers'; |
2 | 3 | ||
3 | export default class UserApi { | 4 | export default class UserApi { |
4 | constructor(server, local) { | 5 | server: any; |
6 | |||
7 | local: any; | ||
8 | |||
9 | constructor(server: any, local: any) { | ||
5 | this.server = server; | 10 | this.server = server; |
6 | this.local = local; | 11 | this.local = local; |
7 | } | 12 | } |
8 | 13 | ||
9 | login(email, password) { | 14 | login(email: string, password: BinaryLike) { |
10 | return this.server.login(email, hash(password)); | 15 | return this.server.login(email, hash(password)); |
11 | } | 16 | } |
12 | 17 | ||
@@ -14,18 +19,18 @@ export default class UserApi { | |||
14 | return this; | 19 | return this; |
15 | } | 20 | } |
16 | 21 | ||
17 | signup(data) { | 22 | signup(data: { password: BinaryLike }) { |
18 | Object.assign(data, { | 23 | Object.assign(data, { |
19 | password: hash(data.password), | 24 | password: hash(data.password), |
20 | }); | 25 | }); |
21 | return this.server.signup(data); | 26 | return this.server.signup(data); |
22 | } | 27 | } |
23 | 28 | ||
24 | password(email) { | 29 | password(email: string) { |
25 | return this.server.retrievePassword(email); | 30 | return this.server.retrievePassword(email); |
26 | } | 31 | } |
27 | 32 | ||
28 | invite(data) { | 33 | invite(data: any) { |
29 | return this.server.inviteUser(data); | 34 | return this.server.inviteUser(data); |
30 | } | 35 | } |
31 | 36 | ||
@@ -33,7 +38,7 @@ export default class UserApi { | |||
33 | return this.server.userInfo(); | 38 | return this.server.userInfo(); |
34 | } | 39 | } |
35 | 40 | ||
36 | updateInfo(data) { | 41 | updateInfo(data: { oldPassword: string; newPassword: string }) { |
37 | const userData = data; | 42 | const userData = data; |
38 | if (userData.oldPassword && userData.newPassword) { | 43 | if (userData.oldPassword && userData.newPassword) { |
39 | userData.oldPassword = hash(userData.oldPassword); | 44 | userData.oldPassword = hash(userData.oldPassword); |
diff --git a/src/api/index.js b/src/api/index.ts index ed6c13488..73f613da1 100644 --- a/src/api/index.js +++ b/src/api/index.ts | |||
@@ -7,12 +7,12 @@ import LocalApi from './LocalApi'; | |||
7 | import NewsApi from './NewsApi'; | 7 | import NewsApi from './NewsApi'; |
8 | import FeaturesApi from './FeaturesApi'; | 8 | import FeaturesApi from './FeaturesApi'; |
9 | 9 | ||
10 | export default (server, local) => ({ | 10 | export default (server: any, local: any) => ({ |
11 | app: new AppApi(server, local), | 11 | app: new AppApi(server), |
12 | services: new ServicesApi(server, local), | 12 | services: new ServicesApi(server, local), |
13 | recipePreviews: new RecipePreviewsApi(server, local), | 13 | recipePreviews: new RecipePreviewsApi(server), |
14 | recipes: new RecipesApi(server, local), | 14 | recipes: new RecipesApi(server), |
15 | features: new FeaturesApi(server, local), | 15 | features: new FeaturesApi(server), |
16 | user: new UserApi(server, local), | 16 | user: new UserApi(server, local), |
17 | local: new LocalApi(server, local), | 17 | local: new LocalApi(server, local), |
18 | news: new NewsApi(server, local), | 18 | news: new NewsApi(server, local), |
diff --git a/src/api/utils/auth.js b/src/api/utils/auth.ts index 07b0c096b..98295d1a4 100644 --- a/src/api/utils/auth.js +++ b/src/api/utils/auth.ts | |||
@@ -15,6 +15,7 @@ export const prepareAuthRequest = ( | |||
15 | 'X-Franz-platform': process.platform, | 15 | 'X-Franz-platform': process.platform, |
16 | 'X-Franz-Timezone-Offset': new Date().getTimezoneOffset(), | 16 | 'X-Franz-Timezone-Offset': new Date().getTimezoneOffset(), |
17 | 'X-Franz-System-Locale': ferdiLocale, | 17 | 'X-Franz-System-Locale': ferdiLocale, |
18 | // @ts-expect-error Property 'headers' does not exist on type '{ method: string; }'. | ||
18 | ...options.headers, | 19 | ...options.headers, |
19 | }, | 20 | }, |
20 | }); | 21 | }); |
@@ -28,5 +29,10 @@ export const prepareAuthRequest = ( | |||
28 | return request; | 29 | return request; |
29 | }; | 30 | }; |
30 | 31 | ||
31 | export const sendAuthRequest = (url, options, auth) => | 32 | export const sendAuthRequest = ( |
33 | url: RequestInfo, | ||
34 | options: { method: string } | undefined, | ||
35 | auth?: boolean, | ||
36 | ) => | ||
37 | // @ts-expect-error Argument of type '{ method: string; } & { mode: string; headers: any; }' is not assignable to parameter of type 'RequestInit | undefined'. | ||
32 | window.fetch(url, prepareAuthRequest(options, auth)); | 38 | window.fetch(url, prepareAuthRequest(options, auth)); |
diff --git a/src/components/settings/services/EditServiceForm.js b/src/components/settings/services/EditServiceForm.js index 179741338..22089ec45 100644 --- a/src/components/settings/services/EditServiceForm.js +++ b/src/components/settings/services/EditServiceForm.js | |||
@@ -8,7 +8,8 @@ import normalizeUrl from 'normalize-url'; | |||
8 | import Form from '../../../lib/Form'; | 8 | import Form from '../../../lib/Form'; |
9 | import Recipe from '../../../models/Recipe'; | 9 | import Recipe from '../../../models/Recipe'; |
10 | import Service from '../../../models/Service'; | 10 | import Service from '../../../models/Service'; |
11 | import Tabs, { TabItem } from '../../ui/Tabs'; | 11 | import Tabs from '../../ui/Tabs/Tabs'; |
12 | import { TabItem } from '../../ui/Tabs/TabItem'; | ||
12 | import Input from '../../ui/Input'; | 13 | import Input from '../../ui/Input'; |
13 | import Toggle from '../../ui/Toggle'; | 14 | import Toggle from '../../ui/Toggle'; |
14 | import Slider from '../../ui/Slider'; | 15 | import Slider from '../../ui/Slider'; |
@@ -262,11 +263,11 @@ class EditServiceForm extends Component { | |||
262 | <span className="settings__header-item"> | 263 | <span className="settings__header-item"> |
263 | {action === 'add' | 264 | {action === 'add' |
264 | ? intl.formatMessage(messages.addServiceHeadline, { | 265 | ? intl.formatMessage(messages.addServiceHeadline, { |
265 | name: recipe.name, | 266 | name: recipe.name, |
266 | }) | 267 | }) |
267 | : intl.formatMessage(messages.editServiceHeadline, { | 268 | : intl.formatMessage(messages.editServiceHeadline, { |
268 | name: service.name !== '' ? service.name : recipe.name, | 269 | name: service.name !== '' ? service.name : recipe.name, |
269 | })} | 270 | })} |
270 | </span> | 271 | </span> |
271 | </div> | 272 | </div> |
272 | <div className="settings__body"> | 273 | <div className="settings__body"> |
@@ -342,11 +343,9 @@ class EditServiceForm extends Component { | |||
342 | {intl.formatMessage(messages.indirectMessageInfo)} | 343 | {intl.formatMessage(messages.indirectMessageInfo)} |
343 | </p> | 344 | </p> |
344 | </> | 345 | </> |
345 | )} | 346 | )} |
346 | {recipe.allowFavoritesDelineationInUnreadCount && ( | 347 | {recipe.allowFavoritesDelineationInUnreadCount && ( |
347 | <Toggle | 348 | <Toggle field={form.$('onlyShowFavoritesInUnreadCount')} /> |
348 | field={form.$('onlyShowFavoritesInUnreadCount')} | ||
349 | /> | ||
350 | )} | 349 | )} |
351 | </div> | 350 | </div> |
352 | 351 | ||
diff --git a/src/components/ui/Tabs/TabItem.js b/src/components/ui/Tabs/TabItem.js deleted file mode 100644 index d0ef4e798..000000000 --- a/src/components/ui/Tabs/TabItem.js +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | |||
3 | import { oneOrManyChildElements } from '../../../prop-types'; | ||
4 | |||
5 | export default class TabItem extends Component { | ||
6 | static propTypes = { | ||
7 | children: oneOrManyChildElements.isRequired, | ||
8 | }; | ||
9 | |||
10 | render() { | ||
11 | const { children } = this.props; | ||
12 | |||
13 | return <>{children}</>; | ||
14 | } | ||
15 | } | ||
diff --git a/src/components/ui/Tabs/TabItem.tsx b/src/components/ui/Tabs/TabItem.tsx new file mode 100644 index 000000000..bd613ddc7 --- /dev/null +++ b/src/components/ui/Tabs/TabItem.tsx | |||
@@ -0,0 +1,3 @@ | |||
1 | import React from 'react'; | ||
2 | |||
3 | export const TabItem = ({ children }) => <>{children}</>; | ||
diff --git a/src/components/ui/Tabs/index.js b/src/components/ui/Tabs/index.js deleted file mode 100644 index e4adb62c7..000000000 --- a/src/components/ui/Tabs/index.js +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | import Tabs from './Tabs'; | ||
2 | import TabItem from './TabItem'; | ||
3 | |||
4 | export default Tabs; | ||
5 | |||
6 | export { TabItem }; | ||
diff --git a/src/features/basicAuth/Form.ts b/src/features/basicAuth/Form.ts index 95721d0e9..e84156d96 100644 --- a/src/features/basicAuth/Form.ts +++ b/src/features/basicAuth/Form.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import Form from '../../lib/Form'; | 1 | import Form from '../../lib/Form'; |
2 | 2 | ||
3 | // @ts-expect-error Expected 0 arguments, but got 1 | ||
3 | export default new Form({ | 4 | export default new Form({ |
4 | fields: { | 5 | fields: { |
5 | user: { | 6 | user: { |
diff --git a/src/features/communityRecipes/store.js b/src/features/communityRecipes/store.ts index 05e18e2f7..a8d358ba0 100644 --- a/src/features/communityRecipes/store.js +++ b/src/features/communityRecipes/store.ts | |||
@@ -4,7 +4,11 @@ import { FeatureStore } from '../utils/FeatureStore'; | |||
4 | const debug = require('debug')('Ferdi:feature:communityRecipes:store'); | 4 | const debug = require('debug')('Ferdi:feature:communityRecipes:store'); |
5 | 5 | ||
6 | export class CommunityRecipesStore extends FeatureStore { | 6 | export class CommunityRecipesStore extends FeatureStore { |
7 | start(stores, actions) { | 7 | stores: any; |
8 | |||
9 | actions: any; | ||
10 | |||
11 | start(stores: any, actions: any) { | ||
8 | debug('start'); | 12 | debug('start'); |
9 | this.stores = stores; | 13 | this.stores = stores; |
10 | this.actions = actions; | 14 | this.actions = actions; |
@@ -18,14 +22,17 @@ export class CommunityRecipesStore extends FeatureStore { | |||
18 | @computed get communityRecipes() { | 22 | @computed get communityRecipes() { |
19 | if (!this.stores) return []; | 23 | if (!this.stores) return []; |
20 | 24 | ||
21 | return this.stores.recipePreviews.dev.map(recipePreview => { | 25 | return this.stores.recipePreviews.dev.map( |
22 | // TODO: Need to figure out if this is even necessary/used | 26 | (recipePreview: { isDevRecipe: boolean; author: any[] }) => { |
23 | recipePreview.isDevRecipe = !!recipePreview.author.some( | 27 | // TODO: Need to figure out if this is even necessary/used |
24 | author => author.email === this.stores.user.data.email, | 28 | recipePreview.isDevRecipe = !!recipePreview.author.some( |
25 | ); | 29 | (author: { email: any }) => |
30 | author.email === this.stores.user.data.email, | ||
31 | ); | ||
26 | 32 | ||
27 | return recipePreview; | 33 | return recipePreview; |
28 | }); | 34 | }, |
35 | ); | ||
29 | } | 36 | } |
30 | } | 37 | } |
31 | 38 | ||
diff --git a/src/features/nightlyBuilds/store.js b/src/features/nightlyBuilds/store.ts index ed06e5a7d..ed06e5a7d 100644 --- a/src/features/nightlyBuilds/store.js +++ b/src/features/nightlyBuilds/store.ts | |||
diff --git a/src/features/publishDebugInfo/store.js b/src/features/publishDebugInfo/store.ts index ed06e5a7d..ed06e5a7d 100644 --- a/src/features/publishDebugInfo/store.js +++ b/src/features/publishDebugInfo/store.ts | |||
diff --git a/src/features/quickSwitch/store.js b/src/features/quickSwitch/store.ts index ed06e5a7d..ed06e5a7d 100644 --- a/src/features/quickSwitch/store.js +++ b/src/features/quickSwitch/store.ts | |||
diff --git a/src/features/serviceProxy/index.js b/src/features/serviceProxy/index.js deleted file mode 100644 index b9320cda9..000000000 --- a/src/features/serviceProxy/index.js +++ /dev/null | |||
@@ -1,38 +0,0 @@ | |||
1 | import { autorun, observable } from 'mobx'; | ||
2 | import { session } from '@electron/remote'; | ||
3 | |||
4 | const debug = require('debug')('Ferdi:feature:serviceProxy'); | ||
5 | |||
6 | export const config = observable({ | ||
7 | isEnabled: true, | ||
8 | }); | ||
9 | |||
10 | export default function init(stores) { | ||
11 | debug('Initializing `serviceProxy` feature'); | ||
12 | |||
13 | autorun(() => { | ||
14 | config.isEnabled = true; | ||
15 | |||
16 | const services = stores.services.enabled; | ||
17 | const proxySettings = stores.settings.proxy; | ||
18 | |||
19 | debug('Service Proxy autorun'); | ||
20 | |||
21 | for (const service of services) { | ||
22 | const s = session.fromPartition(`persist:service-${service.id}`); | ||
23 | |||
24 | if (config.isEnabled) { | ||
25 | const serviceProxyConfig = proxySettings[service.id]; | ||
26 | |||
27 | if (serviceProxyConfig && serviceProxyConfig.isEnabled && serviceProxyConfig.host) { | ||
28 | const proxyHost = `${serviceProxyConfig.host}${serviceProxyConfig.port ? `:${serviceProxyConfig.port}` : ''}`; | ||
29 | debug(`Setting proxy config from service settings for "${service.name}" (${service.id}) to`, proxyHost); | ||
30 | |||
31 | s.setProxy({ proxyRules: proxyHost }, () => { | ||
32 | debug(`Using proxy "${proxyHost}" for "${service.name}" (${service.id})`); | ||
33 | }); | ||
34 | } | ||
35 | } | ||
36 | } | ||
37 | }); | ||
38 | } | ||
diff --git a/src/features/serviceProxy/index.ts b/src/features/serviceProxy/index.ts new file mode 100644 index 000000000..f095b286a --- /dev/null +++ b/src/features/serviceProxy/index.ts | |||
@@ -0,0 +1,54 @@ | |||
1 | import { autorun, observable } from 'mobx'; | ||
2 | import { session } from '@electron/remote'; | ||
3 | |||
4 | const debug = require('debug')('Ferdi:feature:serviceProxy'); | ||
5 | |||
6 | export const config = observable({ | ||
7 | isEnabled: true, | ||
8 | }); | ||
9 | |||
10 | export default function init(stores: { | ||
11 | services: { enabled: any }; | ||
12 | settings: { proxy: any }; | ||
13 | }) { | ||
14 | debug('Initializing `serviceProxy` feature'); | ||
15 | |||
16 | autorun(() => { | ||
17 | config.isEnabled = true; | ||
18 | |||
19 | const services = stores.services.enabled; | ||
20 | const proxySettings = stores.settings.proxy; | ||
21 | |||
22 | debug('Service Proxy autorun'); | ||
23 | |||
24 | for (const service of services) { | ||
25 | const s = session.fromPartition(`persist:service-${service.id}`); | ||
26 | |||
27 | if (config.isEnabled) { | ||
28 | const serviceProxyConfig = proxySettings[service.id]; | ||
29 | |||
30 | if ( | ||
31 | serviceProxyConfig && | ||
32 | serviceProxyConfig.isEnabled && | ||
33 | serviceProxyConfig.host | ||
34 | ) { | ||
35 | const proxyHost = `${serviceProxyConfig.host}${ | ||
36 | serviceProxyConfig.port ? `:${serviceProxyConfig.port}` : '' | ||
37 | }`; | ||
38 | debug( | ||
39 | `Setting proxy config from service settings for "${service.name}" (${service.id}) to`, | ||
40 | proxyHost, | ||
41 | ); | ||
42 | |||
43 | s.setProxy({ proxyRules: proxyHost }) | ||
44 | .then(() => { | ||
45 | debug( | ||
46 | `Using proxy "${proxyHost}" for "${service.name}" (${service.id})`, | ||
47 | ); | ||
48 | }) | ||
49 | .catch(error => console.error(error)); | ||
50 | } | ||
51 | } | ||
52 | } | ||
53 | }); | ||
54 | } | ||
diff --git a/src/features/settingsWS/actions.js b/src/features/settingsWS/actions.ts index 631670c8a..631670c8a 100755 --- a/src/features/settingsWS/actions.js +++ b/src/features/settingsWS/actions.ts | |||
diff --git a/src/features/settingsWS/index.js b/src/features/settingsWS/index.ts index 7771421d6..9bb206d82 100755 --- a/src/features/settingsWS/index.js +++ b/src/features/settingsWS/index.ts | |||
@@ -5,15 +5,16 @@ const debug = require('debug')('Ferdi:feature:settingsWS'); | |||
5 | 5 | ||
6 | export const settingsStore = new SettingsWSStore(); | 6 | export const settingsStore = new SettingsWSStore(); |
7 | 7 | ||
8 | export default function initSettingsWebSocket(stores, actions) { | 8 | export default function initSettingsWebSocket( |
9 | stores: { features: any }, | ||
10 | actions: any, | ||
11 | ) { | ||
9 | const { features } = stores; | 12 | const { features } = stores; |
10 | 13 | ||
11 | // Toggle SettingsWebSocket feature | 14 | // Toggle SettingsWebSocket feature |
12 | reaction( | 15 | reaction( |
13 | () => ( | 16 | () => features.features.isSettingsWSEnabled, |
14 | features.features.isSettingsWSEnabled | 17 | isEnabled => { |
15 | ), | ||
16 | (isEnabled) => { | ||
17 | if (isEnabled) { | 18 | if (isEnabled) { |
18 | debug('Initializing `settingsWS` feature'); | 19 | debug('Initializing `settingsWS` feature'); |
19 | settingsStore.start(stores, actions); | 20 | settingsStore.start(stores, actions); |
diff --git a/src/features/settingsWS/state.js b/src/features/settingsWS/state.ts index 7b16b2b6e..7b16b2b6e 100755 --- a/src/features/settingsWS/state.js +++ b/src/features/settingsWS/state.ts | |||
diff --git a/src/features/todos/actions.js b/src/features/todos/actions.js deleted file mode 100644 index cc17e919b..000000000 --- a/src/features/todos/actions.js +++ /dev/null | |||
@@ -1,28 +0,0 @@ | |||
1 | import PropTypes from 'prop-types'; | ||
2 | import { createActionsFromDefinitions } from '../../actions/lib/actions'; | ||
3 | |||
4 | export const todoActions = createActionsFromDefinitions({ | ||
5 | resize: { | ||
6 | width: PropTypes.number.isRequired, | ||
7 | }, | ||
8 | toggleTodosPanel: {}, | ||
9 | toggleTodosFeatureVisibility: {}, | ||
10 | setTodosWebview: { | ||
11 | webview: PropTypes.instanceOf(Element).isRequired, | ||
12 | }, | ||
13 | handleHostMessage: { | ||
14 | action: PropTypes.string.isRequired, | ||
15 | data: PropTypes.object, | ||
16 | }, | ||
17 | handleClientMessage: { | ||
18 | channel: PropTypes.string.isRequired, | ||
19 | message: PropTypes.shape({ | ||
20 | action: PropTypes.string.isRequired, | ||
21 | data: PropTypes.object, | ||
22 | }), | ||
23 | }, | ||
24 | openDevTools: {}, | ||
25 | reload: {}, | ||
26 | }, PropTypes.checkPropTypes); | ||
27 | |||
28 | export default todoActions; | ||
diff --git a/src/features/todos/actions.ts b/src/features/todos/actions.ts new file mode 100644 index 000000000..04e299e71 --- /dev/null +++ b/src/features/todos/actions.ts | |||
@@ -0,0 +1,31 @@ | |||
1 | import PropTypes from 'prop-types'; | ||
2 | import { createActionsFromDefinitions } from '../../actions/lib/actions'; | ||
3 | |||
4 | export const todoActions = createActionsFromDefinitions( | ||
5 | { | ||
6 | resize: { | ||
7 | width: PropTypes.number.isRequired, | ||
8 | }, | ||
9 | toggleTodosPanel: {}, | ||
10 | toggleTodosFeatureVisibility: {}, | ||
11 | setTodosWebview: { | ||
12 | webview: PropTypes.instanceOf(Element).isRequired, | ||
13 | }, | ||
14 | handleHostMessage: { | ||
15 | action: PropTypes.string.isRequired, | ||
16 | data: PropTypes.object, | ||
17 | }, | ||
18 | handleClientMessage: { | ||
19 | channel: PropTypes.string.isRequired, | ||
20 | message: PropTypes.shape({ | ||
21 | action: PropTypes.string.isRequired, | ||
22 | data: PropTypes.object, | ||
23 | }), | ||
24 | }, | ||
25 | openDevTools: {}, | ||
26 | reload: {}, | ||
27 | }, | ||
28 | PropTypes.checkPropTypes, | ||
29 | ); | ||
30 | |||
31 | export default todoActions; | ||
diff --git a/src/features/todos/constants.js b/src/features/todos/constants.ts index 303a7a16e..303a7a16e 100644 --- a/src/features/todos/constants.js +++ b/src/features/todos/constants.ts | |||
diff --git a/src/features/todos/index.js b/src/features/todos/index.ts index 573190881..3665812e6 100644 --- a/src/features/todos/index.js +++ b/src/features/todos/index.ts | |||
@@ -5,16 +5,17 @@ const debug = require('debug')('Ferdi:feature:todos'); | |||
5 | 5 | ||
6 | export const todosStore = new TodoStore(); | 6 | export const todosStore = new TodoStore(); |
7 | 7 | ||
8 | export default function initTodos(stores, actions) { | 8 | export default function initTodos( |
9 | stores: { todos?: any; features?: any }, | ||
10 | actions: any, | ||
11 | ) { | ||
9 | stores.todos = todosStore; | 12 | stores.todos = todosStore; |
10 | const { features } = stores; | 13 | const { features } = stores; |
11 | 14 | ||
12 | // Toggle todos feature | 15 | // Toggle todos feature |
13 | reaction( | 16 | reaction( |
14 | () => ( | 17 | () => features.features.isTodosEnabled, |
15 | features.features.isTodosEnabled | 18 | isEnabled => { |
16 | ), | ||
17 | (isEnabled) => { | ||
18 | if (isEnabled) { | 19 | if (isEnabled) { |
19 | debug('Initializing `todos` feature'); | 20 | debug('Initializing `todos` feature'); |
20 | todosStore.start(stores, actions); | 21 | todosStore.start(stores, actions); |
diff --git a/src/lib/DBus.js b/src/lib/DBus.ts index 9baaea014..b1febc2d1 100644 --- a/src/lib/DBus.js +++ b/src/lib/DBus.ts | |||
@@ -1,10 +1,12 @@ | |||
1 | import { sessionBus } from 'dbus-next'; | 1 | import { MessageBus, sessionBus } from 'dbus-next'; |
2 | import { isLinux } from '../environment'; | 2 | import { isLinux } from '../environment'; |
3 | 3 | ||
4 | export default class DBus { | 4 | export default class DBus { |
5 | bus = null; | 5 | bus: MessageBus | null = null; |
6 | 6 | ||
7 | constructor(trayIcon) { | 7 | trayIcon: any; |
8 | |||
9 | constructor(trayIcon: any) { | ||
8 | this.trayIcon = trayIcon; | 10 | this.trayIcon = trayIcon; |
9 | } | 11 | } |
10 | 12 | ||
@@ -19,15 +21,23 @@ export default class DBus { | |||
19 | } | 21 | } |
20 | 22 | ||
21 | // HACK Hook onto the MessageBus to track StatusNotifierWatchers | 23 | // HACK Hook onto the MessageBus to track StatusNotifierWatchers |
22 | this.bus._addMatch("type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',path='/org/freedesktop/DBus',member='NameOwnerChanged'"); | 24 | // @ts-expect-error Property '_addMatch' does not exist on type 'MessageBus'. |
25 | this.bus._addMatch( | ||
26 | "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',path='/org/freedesktop/DBus',member='NameOwnerChanged'", | ||
27 | ); | ||
23 | const mangled = JSON.stringify({ | 28 | const mangled = JSON.stringify({ |
24 | path: '/org/freedesktop/DBus', | 29 | path: '/org/freedesktop/DBus', |
25 | interface: 'org.freedesktop.DBus', | 30 | interface: 'org.freedesktop.DBus', |
26 | member: 'NameOwnerChanged', | 31 | member: 'NameOwnerChanged', |
27 | }); | 32 | }); |
28 | this.bus._signals.on(mangled, (msg) => { | 33 | // @ts-expect-error Property '_signals' does not exist on type 'MessageBus'. |
34 | this.bus._signals.on(mangled, (msg: { body: [any, any, any] }) => { | ||
29 | const [name, oldOwner, newOwner] = msg.body; | 35 | const [name, oldOwner, newOwner] = msg.body; |
30 | if (name === 'org.kde.StatusNotifierWatcher' && oldOwner !== newOwner && newOwner !== '') { | 36 | if ( |
37 | name === 'org.kde.StatusNotifierWatcher' && | ||
38 | oldOwner !== newOwner && | ||
39 | newOwner !== '' | ||
40 | ) { | ||
31 | // Leave ample time for the StatusNotifierWatcher to be initialized | 41 | // Leave ample time for the StatusNotifierWatcher to be initialized |
32 | setTimeout(() => { | 42 | setTimeout(() => { |
33 | this.trayIcon.recreateIfVisible(); | 43 | this.trayIcon.recreateIfVisible(); |
diff --git a/src/lib/Form.js b/src/lib/Form.ts index 9b8321948..9b8321948 100644 --- a/src/lib/Form.js +++ b/src/lib/Form.ts | |||
diff --git a/src/lib/TouchBar.js b/src/lib/TouchBar.ts index c80931200..417e20411 100644 --- a/src/lib/TouchBar.js +++ b/src/lib/TouchBar.ts | |||
@@ -5,7 +5,13 @@ import { autorun } from 'mobx'; | |||
5 | import { isMac, osRelease } from '../environment'; | 5 | import { isMac, osRelease } from '../environment'; |
6 | 6 | ||
7 | export default class FranzTouchBar { | 7 | export default class FranzTouchBar { |
8 | constructor(stores, actions) { | 8 | stores: any; |
9 | |||
10 | actions: any; | ||
11 | |||
12 | build: any; | ||
13 | |||
14 | constructor(stores: any, actions: any) { | ||
9 | this.stores = stores; | 15 | this.stores = stores; |
10 | this.actions = actions; | 16 | this.actions = actions; |
11 | 17 | ||
@@ -26,18 +32,25 @@ export default class FranzTouchBar { | |||
26 | if (this.stores.user.isLoggedIn) { | 32 | if (this.stores.user.isLoggedIn) { |
27 | const { TouchBarButton, TouchBarSpacer } = TouchBar; | 33 | const { TouchBarButton, TouchBarSpacer } = TouchBar; |
28 | 34 | ||
29 | const buttons = []; | 35 | const buttons: any[] = []; |
30 | for (const service of this.stores.services.allDisplayed) { | 36 | for (const service of this.stores.services.allDisplayed) { |
31 | buttons.push(new TouchBarButton({ | 37 | buttons.push( |
32 | label: `${service.name}${service.unreadDirectMessageCount > 0 | 38 | new TouchBarButton({ |
33 | ? ' 🔴' : ''} ${service.unreadDirectMessageCount === 0 | 39 | label: `${service.name}${ |
34 | && service.unreadIndirectMessageCount > 0 | 40 | service.unreadDirectMessageCount > 0 ? ' 🔴' : '' |
35 | ? ' ⚪️' : ''}`, | 41 | } ${ |
36 | backgroundColor: service.isActive ? '#3498DB' : null, | 42 | service.unreadDirectMessageCount === 0 && |
37 | click: () => { | 43 | service.unreadIndirectMessageCount > 0 |
38 | this.actions.service.setActive({ serviceId: service.id }); | 44 | ? ' ⚪️' |
39 | }, | 45 | : '' |
40 | }), new TouchBarSpacer({ size: 'small' })); | 46 | }`, |
47 | backgroundColor: service.isActive && '#3498DB', | ||
48 | click: () => { | ||
49 | this.actions.service.setActive({ serviceId: service.id }); | ||
50 | }, | ||
51 | }), | ||
52 | new TouchBarSpacer({ size: 'small' }), | ||
53 | ); | ||
41 | } | 54 | } |
42 | 55 | ||
43 | const touchBar = new TouchBar({ items: buttons }); | 56 | const touchBar = new TouchBar({ items: buttons }); |