From 8e3c47aff5327c52ce92b4821cf4bb54ece5d441 Mon Sep 17 00:00:00 2001 From: Christian Schmidt Date: Tue, 3 Sep 2024 17:55:13 +0200 Subject: [PATCH] [Glitch] `frequentlyUsedLanguages` not updated correctly Port 8adf67f2dbde0ae249ccadd8cbd2156e14932f52 to glitch-soc Signed-off-by: Claire --- app/javascript/flavours/glitch/actions/languages.js | 12 ------------ .../compose/components/language_dropdown.jsx | 4 ---- .../containers/language_dropdown_container.js | 6 ------ app/javascript/flavours/glitch/reducers/settings.js | 4 ++-- 4 files changed, 2 insertions(+), 24 deletions(-) delete mode 100644 app/javascript/flavours/glitch/actions/languages.js diff --git a/app/javascript/flavours/glitch/actions/languages.js b/app/javascript/flavours/glitch/actions/languages.js deleted file mode 100644 index ad186ba0cc..0000000000 --- a/app/javascript/flavours/glitch/actions/languages.js +++ /dev/null @@ -1,12 +0,0 @@ -import { saveSettings } from './settings'; - -export const LANGUAGE_USE = 'LANGUAGE_USE'; - -export const useLanguage = language => dispatch => { - dispatch({ - type: LANGUAGE_USE, - language, - }); - - dispatch(saveSettings()); -}; diff --git a/app/javascript/flavours/glitch/features/compose/components/language_dropdown.jsx b/app/javascript/flavours/glitch/features/compose/components/language_dropdown.jsx index 1ad9e03040..a2efa0d500 100644 --- a/app/javascript/flavours/glitch/features/compose/components/language_dropdown.jsx +++ b/app/javascript/flavours/glitch/features/compose/components/language_dropdown.jsx @@ -240,7 +240,6 @@ class LanguageDropdown extends PureComponent { frequentlyUsedLanguages: PropTypes.arrayOf(PropTypes.string), intl: PropTypes.object.isRequired, onChange: PropTypes.func, - onClose: PropTypes.func, }; state = { @@ -257,14 +256,11 @@ class LanguageDropdown extends PureComponent { }; handleClose = () => { - const { value, onClose } = this.props; - if (this.state.open && this.activeElement) { this.activeElement.focus({ preventScroll: true }); } this.setState({ open: false }); - onClose(value); }; handleChange = value => { diff --git a/app/javascript/flavours/glitch/features/compose/containers/language_dropdown_container.js b/app/javascript/flavours/glitch/features/compose/containers/language_dropdown_container.js index 9388cb0059..7d1b1e8d42 100644 --- a/app/javascript/flavours/glitch/features/compose/containers/language_dropdown_container.js +++ b/app/javascript/flavours/glitch/features/compose/containers/language_dropdown_container.js @@ -4,7 +4,6 @@ import { connect } from 'react-redux'; import { changeComposeLanguage } from 'flavours/glitch/actions/compose'; -import { useLanguage } from 'flavours/glitch/actions/languages'; import LanguageDropdown from '../components/language_dropdown'; @@ -28,11 +27,6 @@ const mapDispatchToProps = dispatch => ({ dispatch(changeComposeLanguage(value)); }, - onClose (value) { - // eslint-disable-next-line react-hooks/rules-of-hooks -- this is not a react hook - dispatch(useLanguage(value)); - }, - }); export default connect(mapStateToProps, mapDispatchToProps)(LanguageDropdown); diff --git a/app/javascript/flavours/glitch/reducers/settings.js b/app/javascript/flavours/glitch/reducers/settings.js index ff4af68752..660b5f11ca 100644 --- a/app/javascript/flavours/glitch/reducers/settings.js +++ b/app/javascript/flavours/glitch/reducers/settings.js @@ -1,8 +1,8 @@ import { Map as ImmutableMap, fromJS } from 'immutable'; import { COLUMN_ADD, COLUMN_REMOVE, COLUMN_MOVE, COLUMN_PARAMS_CHANGE } from '../actions/columns'; +import { COMPOSE_LANGUAGE_CHANGE } from '../actions/compose'; import { EMOJI_USE } from '../actions/emojis'; -import { LANGUAGE_USE } from '../actions/languages'; import { LIST_DELETE_SUCCESS, LIST_FETCH_FAIL } from '../actions/lists'; import { NOTIFICATIONS_FILTER_SET } from '../actions/notifications'; import { SETTING_CHANGE, SETTING_SAVE } from '../actions/settings'; @@ -182,7 +182,7 @@ export default function settings(state = initialState, action) { return changeColumnParams(state, action.uuid, action.path, action.value); case EMOJI_USE: return updateFrequentEmojis(state, action.emoji); - case LANGUAGE_USE: + case COMPOSE_LANGUAGE_CHANGE: return updateFrequentLanguages(state, action.language); case SETTING_SAVE: return state.set('saved', true);