From 7839bbf2a15f861ca28a3549dbd11c696fc81734 Mon Sep 17 00:00:00 2001 From: infiinte-persistence Date: Sun, 28 Jun 2020 00:48:25 +0800 Subject: [PATCH] Fix language-change not applied to all components immediately. ## Fixes: 3641 Language switch does not take effect right away ## Assessment: Although `Card`s in the Settings Page are actually being re-rendered, the `actions` within them might not be getting the signal, depending on their props. ## Changes: (1) Pass the language variable to the `actions`'s props for items that are affected. (2) Make the Wunderbar listen to language-changes as well (the only component outside of Settings that would need an immediate update). --- CHANGELOG.md | 1 + ui/component/wunderbar/index.js | 3 +++ ui/page/settings/index.js | 1 + ui/page/settings/view.jsx | 7 +++++-- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 608b08b1c..e16e320ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - Fix report page layout ([#4384](https://github.com/lbryio/lbry-desktop/pull/4384)) +- Fix language-change not applied to components immediately _community pr!_ ([#4437](https://github.com/lbryio/lbry-desktop/pull/4437)) ## [0.46.2] - [2020-06-10] diff --git a/ui/component/wunderbar/index.js b/ui/component/wunderbar/index.js index bcad5368c..4384effa4 100644 --- a/ui/component/wunderbar/index.js +++ b/ui/component/wunderbar/index.js @@ -6,7 +6,9 @@ import { selectSearchValue, selectSearchSuggestions, selectSearchBarFocused, + SETTINGS, } from 'lbry-redux'; +import { makeSelectClientSetting } from 'redux/selectors/settings'; import { doToast } from 'redux/actions/notifications'; import analytics from 'analytics'; import Wunderbar from './view'; @@ -17,6 +19,7 @@ const select = state => ({ suggestions: selectSearchSuggestions(state), searchQuery: selectSearchValue(state), isFocused: selectSearchBarFocused(state), + language: makeSelectClientSetting(SETTINGS.LANGUAGE)(state), }); const perform = (dispatch, ownProps) => ({ diff --git a/ui/page/settings/index.js b/ui/page/settings/index.js index d13ea8cef..6cbfac8af 100644 --- a/ui/page/settings/index.js +++ b/ui/page/settings/index.js @@ -46,6 +46,7 @@ const select = state => ({ darkModeTimes: makeSelectClientSetting(SETTINGS.DARK_MODE_TIMES)(state), ffmpegStatus: selectFfmpegStatus(state), findingFFmpeg: selectFindingFFmpeg(state), + language: makeSelectClientSetting(SETTINGS.LANGUAGE)(state), }); const perform = dispatch => ({ diff --git a/ui/page/settings/view.jsx b/ui/page/settings/view.jsx index 24c25679a..e011b633d 100644 --- a/ui/page/settings/view.jsx +++ b/ui/page/settings/view.jsx @@ -87,6 +87,7 @@ type Props = { findingFFmpeg: boolean, findFFmpeg: () => void, openModal: string => void, + language?: string, }; type State = { @@ -246,6 +247,7 @@ class SettingsPage extends React.PureComponent { clearCache, findingFFmpeg, openModal, + language, } = this.props; const { storedPassword } = this.state; const noDaemonSettings = !daemonSettings || Object.keys(daemonSettings).length === 0; @@ -277,7 +279,7 @@ class SettingsPage extends React.PureComponent { ? __("To enable this feature, check 'Save Password' the next time you start the app.") : null } - actions={} + actions={} /> { {!disableMaxKeyFee && ( { {/* @if TARGET='app' */} {/* Auto launch in a hidden state doesn't work on mac https://github.com/Teamwork/node-auto-launch/issues/81 */} - {!IS_MAC && } />} + {!IS_MAC && } />} {/* @endif */}