From 2cd691d0f993a345113bbbd829478ab28a436510 Mon Sep 17 00:00:00 2001 From: infinite-persistence Date: Mon, 9 Aug 2021 13:50:11 +0800 Subject: [PATCH] Re-render on language change Room for improvement: refactor into `` so we don't have to repeat this everywhere. --- ui/component/settingAccount/index.js | 3 +++ ui/component/settingAppearance/index.js | 3 ++- ui/component/settingContent/index.js | 4 +++- ui/component/settingSystem/index.js | 9 ++++++++- ui/component/settingUnauthenticated/index.js | 3 ++- ui/page/settings/index.js | 6 ++++-- 6 files changed, 22 insertions(+), 6 deletions(-) diff --git a/ui/component/settingAccount/index.js b/ui/component/settingAccount/index.js index 596776c1f..83d77af76 100644 --- a/ui/component/settingAccount/index.js +++ b/ui/component/settingAccount/index.js @@ -1,12 +1,15 @@ import { connect } from 'react-redux'; import { doWalletStatus, selectWalletIsEncrypted } from 'lbry-redux'; import { selectUser, selectUserVerifiedEmail } from 'redux/selectors/user'; +import { selectLanguage } from 'redux/selectors/settings'; + import SettingAccount from './view'; const select = (state) => ({ isAuthenticated: selectUserVerifiedEmail(state), walletEncrypted: selectWalletIsEncrypted(state), user: selectUser(state), + language: selectLanguage(state), }); const perform = (dispatch) => ({ diff --git a/ui/component/settingAppearance/index.js b/ui/component/settingAppearance/index.js index d00c404e8..33cea31fc 100644 --- a/ui/component/settingAppearance/index.js +++ b/ui/component/settingAppearance/index.js @@ -1,7 +1,7 @@ import { connect } from 'react-redux'; import { SETTINGS } from 'lbry-redux'; import { doSetClientSetting } from 'redux/actions/settings'; -import { makeSelectClientSetting } from 'redux/selectors/settings'; +import { selectLanguage, makeSelectClientSetting } from 'redux/selectors/settings'; import { selectUserVerifiedEmail } from 'redux/selectors/user'; import SettingAppearance from './view'; @@ -10,6 +10,7 @@ const select = (state) => ({ searchInLanguage: makeSelectClientSetting(SETTINGS.SEARCH_IN_LANGUAGE)(state), isAuthenticated: selectUserVerifiedEmail(state), hideBalance: makeSelectClientSetting(SETTINGS.HIDE_BALANCE)(state), + language: selectLanguage(state), }); const perform = (dispatch) => ({ diff --git a/ui/component/settingContent/index.js b/ui/component/settingContent/index.js index 766f5efff..706b8562b 100644 --- a/ui/component/settingContent/index.js +++ b/ui/component/settingContent/index.js @@ -3,8 +3,9 @@ import { selectMyChannelUrls, SETTINGS } from 'lbry-redux'; import { doOpenModal } from 'redux/actions/app'; import { doSetPlayingUri } from 'redux/actions/content'; import { doSetClientSetting } from 'redux/actions/settings'; -import { selectShowMatureContent, makeSelectClientSetting } from 'redux/selectors/settings'; +import { selectShowMatureContent, selectLanguage, makeSelectClientSetting } from 'redux/selectors/settings'; import { selectUserVerifiedEmail } from 'redux/selectors/user'; + import SettingContent from './view'; const select = (state) => ({ @@ -17,6 +18,7 @@ const select = (state) => ({ instantPurchaseEnabled: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_ENABLED)(state), instantPurchaseMax: makeSelectClientSetting(SETTINGS.INSTANT_PURCHASE_MAX)(state), enablePublishPreview: makeSelectClientSetting(SETTINGS.ENABLE_PUBLISH_PREVIEW)(state), + language: selectLanguage(state), }); const perform = (dispatch) => ({ diff --git a/ui/component/settingSystem/index.js b/ui/component/settingSystem/index.js index 1d7cacc02..53155e49d 100644 --- a/ui/component/settingSystem/index.js +++ b/ui/component/settingSystem/index.js @@ -9,8 +9,14 @@ import { } from 'redux/actions/app'; import { doSetDaemonSetting, doClearDaemonSetting, doFindFFmpeg } from 'redux/actions/settings'; import { selectAllowAnalytics } from 'redux/selectors/app'; -import { selectDaemonSettings, selectFfmpegStatus, selectFindingFFmpeg } from 'redux/selectors/settings'; +import { + selectDaemonSettings, + selectFfmpegStatus, + selectFindingFFmpeg, + selectLanguage, +} from 'redux/selectors/settings'; import { selectUserVerifiedEmail } from 'redux/selectors/user'; + import SettingSystem from './view'; const select = (state) => ({ @@ -20,6 +26,7 @@ const select = (state) => ({ walletEncrypted: selectWalletIsEncrypted(state), isAuthenticated: selectUserVerifiedEmail(state), allowAnalytics: selectAllowAnalytics(state), + language: selectLanguage(state), }); const perform = (dispatch) => ({ diff --git a/ui/component/settingUnauthenticated/index.js b/ui/component/settingUnauthenticated/index.js index 7f9b623a0..8476d4a40 100644 --- a/ui/component/settingUnauthenticated/index.js +++ b/ui/component/settingUnauthenticated/index.js @@ -1,12 +1,13 @@ import { connect } from 'react-redux'; import { SETTINGS } from 'lbry-redux'; import { doSetClientSetting } from 'redux/actions/settings'; -import { makeSelectClientSetting } from 'redux/selectors/settings'; +import { selectLanguage, makeSelectClientSetting } from 'redux/selectors/settings'; import SettingUnauthenticated from './view'; const select = (state) => ({ searchInLanguage: makeSelectClientSetting(SETTINGS.SEARCH_IN_LANGUAGE)(state), + language: selectLanguage(state), }); const perform = (dispatch) => ({ diff --git a/ui/page/settings/index.js b/ui/page/settings/index.js index c8fa27126..35df01630 100644 --- a/ui/page/settings/index.js +++ b/ui/page/settings/index.js @@ -1,12 +1,14 @@ import { connect } from 'react-redux'; import { doEnterSettingsPage, doExitSettingsPage } from 'redux/actions/settings'; -import { selectDaemonSettings } from 'redux/selectors/settings'; -import SettingsPage from './view'; +import { selectDaemonSettings, selectLanguage } from 'redux/selectors/settings'; import { selectUserVerifiedEmail } from 'redux/selectors/user'; +import SettingsPage from './view'; + const select = (state) => ({ daemonSettings: selectDaemonSettings(state), isAuthenticated: selectUserVerifiedEmail(state), + language: selectLanguage(state), }); const perform = (dispatch) => ({