diff options
author | 2023-07-29 21:12:16 -0600 | |
---|---|---|
committer | 2023-07-30 08:42:16 +0530 | |
commit | 32f76b74a69ad4d60a014bf075c39517888436bc (patch) | |
tree | 753378cc30f52d1e0e51be64b5a83d39f08f39c8 /src/components/settings | |
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/components/settings')
3 files changed, 40 insertions, 41 deletions
diff --git a/src/components/settings/releaseNotes/ReleaseNotesDashboard.tsx b/src/components/settings/releaseNotes/ReleaseNotesDashboard.tsx index ff7c45bb1..9b17e551c 100644 --- a/src/components/settings/releaseNotes/ReleaseNotesDashboard.tsx +++ b/src/components/settings/releaseNotes/ReleaseNotesDashboard.tsx | |||
@@ -1,6 +1,6 @@ | |||
1 | import { Component } from 'react'; | 1 | import { Component } from 'react'; |
2 | import { observer } from 'mobx-react'; | 2 | import { observer } from 'mobx-react'; |
3 | import { defineMessages, injectIntl } from 'react-intl'; | 3 | import { IntlShape, defineMessages, injectIntl } from 'react-intl'; |
4 | import Markdown from 'markdown-to-jsx'; | 4 | import Markdown from 'markdown-to-jsx'; |
5 | import { ferdiumVersion } from '../../../environment-remote'; | 5 | import { ferdiumVersion } from '../../../environment-remote'; |
6 | import { | 6 | import { |
@@ -26,14 +26,14 @@ const messages = defineMessages({ | |||
26 | }); | 26 | }); |
27 | 27 | ||
28 | interface IProps { | 28 | interface IProps { |
29 | intl: any; | 29 | intl: IntlShape; |
30 | } | 30 | } |
31 | 31 | ||
32 | class ReleaseNotesDashboard extends Component<IProps> { | 32 | interface IState { |
33 | state = { | 33 | data: string; |
34 | data: '', | 34 | } |
35 | }; | ||
36 | 35 | ||
36 | class ReleaseNotesDashboard extends Component<IProps, IState> { | ||
37 | constructor(props) { | 37 | constructor(props) { |
38 | super(props); | 38 | super(props); |
39 | 39 | ||
diff --git a/src/components/settings/releaseNotes/ReleaseNotesLayout.tsx b/src/components/settings/releaseNotes/ReleaseNotesLayout.tsx index bc38aa603..4a6fe54f4 100644 --- a/src/components/settings/releaseNotes/ReleaseNotesLayout.tsx +++ b/src/components/settings/releaseNotes/ReleaseNotesLayout.tsx | |||
@@ -19,6 +19,7 @@ const messages = defineMessages({ | |||
19 | 19 | ||
20 | interface IProps extends WrappedComponentProps { | 20 | interface IProps extends WrappedComponentProps { |
21 | actions?: Actions; | 21 | actions?: Actions; |
22 | // eslint-disable-next-line react/no-unused-prop-types | ||
22 | children?: React.ReactNode; | 23 | children?: React.ReactNode; |
23 | } | 24 | } |
24 | 25 | ||
diff --git a/src/components/settings/settings/EditSettingsForm.tsx b/src/components/settings/settings/EditSettingsForm.tsx index 11ae63737..099a27ebe 100644 --- a/src/components/settings/settings/EditSettingsForm.tsx +++ b/src/components/settings/settings/EditSettingsForm.tsx | |||
@@ -333,7 +333,7 @@ class EditSettingsForm extends Component<IProps, IState> { | |||
333 | } | 333 | } |
334 | 334 | ||
335 | this.props.form.submit({ | 335 | this.props.form.submit({ |
336 | onSuccess: form => { | 336 | onSuccess: (form: Form) => { |
337 | const values = form.values(); | 337 | const values = form.values(); |
338 | const { accentColor } = values; | 338 | const { accentColor } = values; |
339 | if (accentColor.trim().length === 0) { | 339 | if (accentColor.trim().length === 0) { |
@@ -386,8 +386,9 @@ class EditSettingsForm extends Component<IProps, IState> { | |||
386 | const { lockingFeatureEnabled, scheduledDNDEnabled, reloadAfterResume } = | 386 | const { lockingFeatureEnabled, scheduledDNDEnabled, reloadAfterResume } = |
387 | window['ferdium'].stores.settings.all.app; | 387 | window['ferdium'].stores.settings.all.app; |
388 | 388 | ||
389 | let cacheSize; | 389 | let cacheSize: string; |
390 | let notCleared; | 390 | let notCleared: boolean; |
391 | |||
391 | if (this.state.activeSetttingsTab === 'advanced') { | 392 | if (this.state.activeSetttingsTab === 'advanced') { |
392 | const cacheSizeBytes = getCacheSize(); | 393 | const cacheSizeBytes = getCacheSize(); |
393 | debug('cacheSizeBytes:', cacheSizeBytes); | 394 | debug('cacheSizeBytes:', cacheSizeBytes); |
@@ -740,38 +741,35 @@ class EditSettingsForm extends Component<IProps, IState> { | |||
740 | defaultAccentColor: DEFAULT_APP_SETTINGS.accentColor, | 741 | defaultAccentColor: DEFAULT_APP_SETTINGS.accentColor, |
741 | })} | 742 | })} |
742 | </p> | 743 | </p> |
743 | <p> | 744 | <p>{intl.formatMessage(messages.overallTheme)}</p> |
744 | {intl.formatMessage(messages.overallTheme)} | 745 | <div className="settings__settings-group__apply-color"> |
745 | <div className="settings__settings-group__apply-color"> | 746 | <ColorPickerInput |
746 | <ColorPickerInput | 747 | {...form.$('accentColor').bind()} |
747 | {...form.$('accentColor').bind()} | 748 | name="accentColor" |
748 | onColorChange={this.submit.bind(this)} | 749 | onColorChange={e => this.submit(e)} |
749 | className="color-picker-input" | 750 | className="color-picker-input" |
750 | /> | 751 | /> |
751 | </div> | 752 | </div> |
752 | </p> | 753 | <p>{intl.formatMessage(messages.progressbarTheme)}</p> |
753 | <p> | 754 | <div className="settings__settings-group__apply-color"> |
754 | {intl.formatMessage(messages.progressbarTheme)} | 755 | <ColorPickerInput |
755 | <div className="settings__settings-group__apply-color"> | 756 | {...form.$('progressbarAccentColor').bind()} |
756 | <ColorPickerInput | 757 | name="progressbarAccentColor" |
757 | {...form.$('progressbarAccentColor').bind()} | 758 | onColorChange={e => this.submit(e)} |
758 | onColorChange={this.submit.bind(this)} | 759 | className="color-picker-input" |
759 | className="color-picker-input" | 760 | /> |
760 | /> | 761 | </div> |
761 | </div> | 762 | |
762 | </p> | 763 | <div className="settings__settings-group__apply-color"> |
763 | <p> | 764 | <Button |
764 | <div className="settings__settings-group__apply-color"> | 765 | buttonType="secondary" |
765 | <Button | 766 | className="settings__settings-group__apply-color__button" |
766 | buttonType="secondary" | 767 | label="Apply color" |
767 | className="settings__settings-group__apply-color__button" | 768 | onClick={e => { |
768 | label="Apply color" | 769 | this.submit(e); |
769 | onClick={e => { | 770 | }} |
770 | this.submit(e); | 771 | /> |
771 | }} | 772 | </div> |
772 | /> | ||
773 | </div> | ||
774 | </p> | ||
775 | <HrSections /> | 773 | <HrSections /> |
776 | 774 | ||
777 | <H2 className="settings__section_header"> | 775 | <H2 className="settings__section_header"> |