diff options
author | 2022-07-07 09:31:50 +0200 | |
---|---|---|
committer | 2022-07-07 09:31:50 +0200 | |
commit | 71c52373f81cace664047edd19d9d289f45a4dff (patch) | |
tree | 69b3f1d45a8b3f1ceab9497ea3c96e9dc18e3166 /src/containers/settings/EditServiceScreen.tsx | |
parent | 6.0.0-nightly.91 [skip ci] (diff) | |
download | ferdium-app-71c5237.tar.gz ferdium-app-71c5237.tar.zst ferdium-app-71c5237.zip |
chore: Mobx & React-Router upgrade (#406)
Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
Diffstat (limited to 'src/containers/settings/EditServiceScreen.tsx')
-rw-r--r-- | src/containers/settings/EditServiceScreen.tsx | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/containers/settings/EditServiceScreen.tsx b/src/containers/settings/EditServiceScreen.tsx index f8532a7b4..ba8f374c3 100644 --- a/src/containers/settings/EditServiceScreen.tsx +++ b/src/containers/settings/EditServiceScreen.tsx | |||
@@ -2,7 +2,7 @@ import { Component, ReactElement } from 'react'; | |||
2 | import { inject, observer } from 'mobx-react'; | 2 | import { inject, observer } from 'mobx-react'; |
3 | import { defineMessages, injectIntl } from 'react-intl'; | 3 | import { defineMessages, injectIntl } from 'react-intl'; |
4 | 4 | ||
5 | import { RouterStore } from 'mobx-react-router'; | 5 | import { Params } from 'react-router-dom'; |
6 | import { StoresProps } from '../../@types/ferdium-components.types'; | 6 | import { StoresProps } from '../../@types/ferdium-components.types'; |
7 | import { IRecipe } from '../../models/Recipe'; | 7 | import { IRecipe } from '../../models/Recipe'; |
8 | import Service from '../../models/Service'; | 8 | import Service from '../../models/Service'; |
@@ -22,6 +22,7 @@ import { SPELLCHECKER_LOCALES } from '../../i18n/languages'; | |||
22 | 22 | ||
23 | import globalMessages from '../../i18n/globalMessages'; | 23 | import globalMessages from '../../i18n/globalMessages'; |
24 | import { DEFAULT_APP_SETTINGS, DEFAULT_SERVICE_SETTINGS } from '../../config'; | 24 | import { DEFAULT_APP_SETTINGS, DEFAULT_SERVICE_SETTINGS } from '../../config'; |
25 | import withParams from '../../components/util/WithParams'; | ||
25 | 26 | ||
26 | const messages = defineMessages({ | 27 | const messages = defineMessages({ |
27 | name: { | 28 | name: { |
@@ -119,14 +120,13 @@ const messages = defineMessages({ | |||
119 | }); | 120 | }); |
120 | 121 | ||
121 | interface EditServicesScreenProps extends StoresProps { | 122 | interface EditServicesScreenProps extends StoresProps { |
122 | router: RouterStore; | ||
123 | intl: any; | 123 | intl: any; |
124 | params: Params; | ||
124 | } | 125 | } |
125 | 126 | ||
126 | class EditServiceScreen extends Component<EditServicesScreenProps> { | 127 | class EditServiceScreen extends Component<EditServicesScreenProps> { |
127 | onSubmit(data: any) { | 128 | onSubmit(data: any) { |
128 | // @ts-ignore TODO: This is actually there and we don't have a correct type right now. | 129 | const { action } = this.props.params; |
129 | const { action } = this.props.router.params; | ||
130 | const { recipes, services } = this.props.stores; | 130 | const { recipes, services } = this.props.stores; |
131 | const { createService, updateService } = this.props.actions.service; | 131 | const { createService, updateService } = this.props.actions.service; |
132 | data.darkReaderSettings = { | 132 | data.darkReaderSettings = { |
@@ -151,10 +151,9 @@ class EditServiceScreen extends Component<EditServicesScreenProps> { | |||
151 | prepareForm(recipe: IRecipe, service: Service | null, proxy: any): Form { | 151 | prepareForm(recipe: IRecipe, service: Service | null, proxy: any): Form { |
152 | const { intl } = this.props; | 152 | const { intl } = this.props; |
153 | 153 | ||
154 | const { stores, router } = this.props; | 154 | const { stores } = this.props; |
155 | 155 | ||
156 | // @ts-ignore TODO: This is actually there and we don't have a correct type right now. | 156 | const { action } = stores.router.pathValue; |
157 | const { action } = router.params; | ||
158 | 157 | ||
159 | let defaultSpellcheckerLanguage = | 158 | let defaultSpellcheckerLanguage = |
160 | SPELLCHECKER_LOCALES[stores.settings.app.spellcheckerLanguage]; | 159 | SPELLCHECKER_LOCALES[stores.settings.app.spellcheckerLanguage]; |
@@ -389,8 +388,7 @@ class EditServiceScreen extends Component<EditServicesScreenProps> { | |||
389 | 388 | ||
390 | deleteService(): void { | 389 | deleteService(): void { |
391 | const { deleteService } = this.props.actions.service; | 390 | const { deleteService } = this.props.actions.service; |
392 | // @ts-ignore TODO: This is actually there and we don't have a correct type right now. | 391 | const { action } = this.props.params; |
393 | const { action } = this.props.router.params; | ||
394 | 392 | ||
395 | if (action === 'edit') { | 393 | if (action === 'edit') { |
396 | const { activeSettings: service } = this.props.stores.services; | 394 | const { activeSettings: service } = this.props.stores.services; |
@@ -403,8 +401,7 @@ class EditServiceScreen extends Component<EditServicesScreenProps> { | |||
403 | 401 | ||
404 | openRecipeFile(file: any): void { | 402 | openRecipeFile(file: any): void { |
405 | const { openRecipeFile } = this.props.actions.service; | 403 | const { openRecipeFile } = this.props.actions.service; |
406 | // @ts-ignore TODO: This is actually there and we don't have a correct type right now. | 404 | const { action } = this.props.params; |
407 | const { action } = this.props.router.params; | ||
408 | 405 | ||
409 | if (action === 'edit') { | 406 | if (action === 'edit') { |
410 | const { activeSettings: service } = this.props.stores.services; | 407 | const { activeSettings: service } = this.props.stores.services; |
@@ -417,9 +414,7 @@ class EditServiceScreen extends Component<EditServicesScreenProps> { | |||
417 | 414 | ||
418 | render(): ReactElement { | 415 | render(): ReactElement { |
419 | const { recipes, services, user } = this.props.stores; | 416 | const { recipes, services, user } = this.props.stores; |
420 | 417 | const { action } = this.props.params; | |
421 | // @ts-ignore TODO: This is actually there and we don't have a correct type right now. | ||
422 | const { action } = this.props.router.params; | ||
423 | 418 | ||
424 | let recipe: null | IRecipe = null; | 419 | let recipe: null | IRecipe = null; |
425 | let service: null | Service = null; | 420 | let service: null | Service = null; |
@@ -427,7 +422,6 @@ class EditServiceScreen extends Component<EditServicesScreenProps> { | |||
427 | 422 | ||
428 | if (action === 'add') { | 423 | if (action === 'add') { |
429 | recipe = recipes.active; | 424 | recipe = recipes.active; |
430 | |||
431 | // TODO: render error message when recipe is `null` | 425 | // TODO: render error message when recipe is `null` |
432 | if (!recipe) { | 426 | if (!recipe) { |
433 | return <ServiceError />; | 427 | return <ServiceError />; |
@@ -475,6 +469,8 @@ class EditServiceScreen extends Component<EditServicesScreenProps> { | |||
475 | } | 469 | } |
476 | } | 470 | } |
477 | 471 | ||
478 | export default injectIntl<'intl', EditServicesScreenProps>( | 472 | export default withParams( |
479 | inject('stores', 'actions')(observer(EditServiceScreen)), | 473 | injectIntl<'intl', EditServicesScreenProps>( |
474 | inject('stores', 'actions')(observer(EditServiceScreen)), | ||
475 | ), | ||
480 | ); | 476 | ); |